From: Remenic (remenic@remenic.2y.net)
Date: Fri 03 Nov 2000 - 10:55:21 IST
Hey, I finally figured out how to adjust the palette (with help of the .pal files from PSP7), however, I would like to know how to fade one... I tried creating a loop, and decreased all the color numbers in it, however this didn't work. Colors just got messed up for some _wierd_ reason... I was hoping someone could take a look at the source, and tell me what's wrong with it.... Here's the source: ------------------------- #include <iostream.h> #include <fstream.h> #include <vga.h> #include <vgagl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #define LOGOWIDTH 640 #define LOGOHEIGHT 480 static GraphicsContext *physicalscreen; static GraphicsContext *virtualscreen; static GraphicsContext *logoscreen; void *logobitmap; int getpalette(char *file, int shade) { ifstream pal(file); int r,g,b,svga_red,svga_green,svga_blue,c = 0; while (pal) { pal >> r; pal >> g; pal >> b; r = r - shade; g = g - shade; b = b - shade; svga_red = ((r >> 2) & 0x3f); svga_green = ((g >> 2) & 0x3f); svga_blue = ((b >> 2) & 0x3f); gl_setpalettecolor(c,svga_red,svga_green,svga_blue); c++; } } void loadbitmap(char *filename, void *buf) { FILE *f; f = fopen(filename, "rb"); if(f==NULL)return; fread(buf, 1, 307220, f); fclose(f); } void logotest(int x, int y) { void *final; final = alloca(WIDTH*HEIGHT); logobitmap = alloca(LOGOWIDTH * LOGOHEIGHT); loadbitmap("rc2k.raw", logobitmap); gl_putbox(x, y, LOGOWIDTH, LOGOHEIGHT, logobitmap); } int main() { vga_init(); vga_setmode(10); gl_setcontextvga(10); physicalscreen = gl_allocatecontext(); gl_getcontext(physicalscreen); gl_setcontextvgavirtual(10); virtualscreen = gl_allocatecontext(); gl_getcontext(virtualscreen); gl_setcontextvgavirtual(10); logoscreen = gl_allocatecontext(); gl_getcontext(logoscreen); getpalette("rc2k.pal",0); // this is the palette file created by PSP7 gl_setpalettecolor(0,0,0,0); gl_setcontext(virtualscreen); sleep(1); // wait till screen is reeaaallly initiated... for (int y=0;y<255;y++) { // this should do the fading. logotest(0,0); // sets the logo at position 0,0. gl_copyscreen(physicalscreen); getpalette("rc2k.pal",y); gl_setpalettecolor(0,0,0,0); } sleep(2); } ------------------------------- The image only contains blue shades (and white ones), but when shading the palette, I get red, and other colors that shouldn't be there.... Any help would be appreciated. thnx in advance, - Remenic. -- _____________________________________________________ Richard 'Remenic' Stellingwerff remenic@remenic.2y.net http://remenic.2y.net ------------------------------------------------------------------ Unsubscribe: To: listbot@svgalib.org Body: unsubscribe linux-svgalib
This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST