This is my first time using IM. I am trying to create a GIF image using Magick++, but I am having difficulties getting the colors right. Whatever I do, it seems that the file that is created only has a very limited number of colors. I am probably missing something here, so any help would be appreciated!
The following code is supposed to make a 73*14 GIF image (works), make the background black (works), and draw a number of pixels with a gradient of R/G combinations (which are stored in the array colors[16][16], where the two array indices represent values for red and green).
Code: Select all
Color colors[16][16]; //all tints of r/g in an array
//generate all the array's colors for the visible palette in the image:
int r = 0;
int g = 0;
while(r<16)
{
while(g<16)
{
colors[r][g] = ColorRGB((double)(r*16), (double)(g*16), 0);
g++;
}
r++;
g = 0;
}
Image result; //make an image
result.depth(24); //bit depth
result.size( Geometry(73, 14) ); //image size
result.backgroundColor( colors[0][0] ); //background color
result.compressType( NoCompression ); //No compression enabled
result.gifDisposeMethod(1); //fastest frame disposal (none)
int x = 0;
int y = 1;
r = g = 0;
//display a list of all important colors
while(r<16)
{
while(g<16)
{
result.pixelColor(x, y, colors[r][g]);
x++; //next position
if(x >= 73) //end of line
{
x = 0;
y++;
}
g++;
}
g = 0;
r++;
}
//construct the filename
//string str1 = LCCUBEANIMATION_PATHPRE; //add the directory to the filename
string str1 = "";
str1.append(filename);
str1.append(LCCUBEANIMATION_PATHPOSTGIF); //add the filetype to the filename
result.write(str1); //attempt to write the image
I am using Visual C++ 2008 Express, with a precompiled binary release of ImageMagick that was installed in 16-bit dll mode.