Page 1 of 1

problems using colormap with gflC

Posted: Sun Jun 17, 2007 9:49 am
by stolarz
hi :)
i'm trying to create a 256-color bitmap. when i do it with libgfl functions everything is fine, the code:

Code: Select all

	GFL_BITMAP *b2 = gflAllockBitmap(GFL_COLORS, wh+2*margin, wh+2*margin, 4, NULL);
	GFL_COLORMAP cm2;
	cm2.Red[0]=0; cm2.Green[0]=0; cm2.Blue[0]=0;
	cm2.Red[1]=255; cm2.Green[1]=255; cm2.Blue[1]=255;
	cm2.Red[2]=255; cm2.Green[2]=0; cm2.Blue[2]=0;
	b2->ColorMap = &cm2;
	GFL_COLOR black1 = {0,0,0,0};
	GFL_COLOR white1 = {255,255,255,0};
	GFL_COLOR red1 = {255,0,0,0};
	gflSetColorAt(b2, 0, 0, &black1);
	gflSetColorAt(b2, 1, 0, &white1);
	gflSetColorAt(b2, 2, 0, &red1);

	GFL_SAVE_PARAMS sp1;
	gflGetDefaultSaveParams(&sp1);
	sp1.FormatIndex = gflGetFormatIndexByName("bmp");
	e = gflSaveBitmap("b.bmp", b2, &sp1);
gives the desired results, but i tried to do that with gflC:

Code: Select all

	GFLC_BITMAP b1(GFL_COLORS, wh+2*margin, wh+2*margin, 4);

	GFL_COLORMAP cm1;
	cm1.Red[0]=0; cm1.Green[0]=0; cm1.Blue[0]=0;
	cm1.Red[1]=255; cm1.Green[1]=255; cm1.Blue[1]=255;
	cm1.Red[2]=255; cm1.Green[2]=0; cm1.Blue[2]=0;

	b1.getColorMap().set(&cm1);

	GFLC_COLOR black(0,0,0);
	GFLC_COLOR white(255,255,255);
	GFLC_COLOR red(255,0,0);
	b1.setPixel(0,0,black);
	b1.setPixel(1,0,white);
	b1.setPixel(2,0,red);

	b1.saveIntoFile("a.bmp", "bmp");
and it didn't work, the bitmap was all black and when i switched to the hexview i saw that the colormap is all zeroes.

gflGetVersion() = 2.71
gflGetVersionOfLibformat() = 4.79

Posted: Sun Jun 17, 2007 10:35 am
by stolarz
post scriptum: is there any way to use color index when putting pixels on bitmap? i mean sth like gflSetColorAt(bmp, 0, 0, 5) where 5 is the 6th color in the palette (0 is origin)

Posted: Mon Jun 18, 2007 7:05 am
by xnview
stolarz wrote:post scriptum: is there any way to use color index when putting pixels on bitmap? i mean sth like gflSetColorAt(bmp, 0, 0, 5) where 5 is the 6th color in the palette (0 is origin)
Ok, i check and add that