本文整理汇总了C++中BitmapStorage::SetPalette方法的典型用法代码示例。如果您正苦于以下问题:C++ BitmapStorage::SetPalette方法的具体用法?C++ BitmapStorage::SetPalette怎么用?C++ BitmapStorage::SetPalette使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitmapStorage
的用法示例。
在下文中一共展示了BitmapStorage::SetPalette方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: palette
//.........这里部分代码省略.........
unsigned char *inbyte = row_pointers[iy];
for (png_uint_32 ix = 0; ix < info->width; inbyte++) {
switch(info->bit_depth) {
case 2:
pixels[ix] = (*inbyte & 0xc0) >> 6;
ix++; if (ix >= info->width) break;
pixels[ix] = (*inbyte & 0x30) >> 4;
ix++; if (ix >= info->width) break;
pixels[ix] = (*inbyte & 0x0c) >> 2;
ix++; if (ix >= info->width) break;
pixels[ix] = *inbyte & 0x03;
ix++;
break;
case 4:
pixels[ix] = (*inbyte & 0xf0) >> 4;
ix++; if (ix >= info->width) break;
pixels[ix] = *inbyte & 0x0f;
ix++;
break;
}
}
storage->PutIndexPixels(0, iy, info->width, pixels);
}
free(pixels);
}
// Now the palette
PixelBuf48 palette(256);
BMM_Color_48 *palout = palette.Ptr();
for(int i = 0; i < png->num_palette; ++i,++palout) {
palout->r = (USHORT)png->palette[i].red << 8;
palout->g = (USHORT)png->palette[i].green << 8;
palout->b = (USHORT)png->palette[i].blue << 8;
}
storage->SetPalette(0, png->num_palette, palette.Ptr());
}
break;
case BMM_TRUE_32: {
BMM_Color_64 *line64 = (BMM_Color_64 *) calloc(info->width, sizeof(BMM_Color_64));
for (png_uint_32 iy = 0; iy < info->height; iy++) {
BMM_Color_64 *l64 = line64;
for (png_uint_32 ix = 0; ix < info->rowbytes; l64++) {
l64->r = (unsigned short) (row_pointers[iy][ix++]) << 8;
l64->g = (unsigned short) (row_pointers[iy][ix++]) << 8;
l64->b = (unsigned short) (row_pointers[iy][ix++]) << 8;
if (info->channels == 4) {
l64->a = (unsigned short) (row_pointers[iy][ix++]) << 8;
} else
l64->a = 0;
}
storage->PutPixels(0, iy, info->width, line64);
}
free(line64);
}
break;
case BMM_TRUE_64: {
BMM_Color_64 *line64 = (BMM_Color_64 *) calloc(info->width, sizeof(BMM_Color_64));
for (png_uint_32 iy = 0; iy < info->height; iy++) {
BMM_Color_64 *l64 = line64;
unsigned short *row = (unsigned short *) row_pointers[iy];
for (png_uint_32 ix = 0; ix < info->width; ix++, l64++) {
l64->r = *row++;
l64->g = *row++;
l64->b = *row++;
if (info->channels == 4) {
l64->a = *row++;
} else
示例2: palette
BitmapStorage *
BitmapIO_GIF::LoadGIFStuff(BitmapInfo *fbi, BitmapManager *manager ){
BitmapStorage *s = NULL;
gif_line = 0;
iphase=0;
iy=0;
if(image.flags&COLTAB) {
gif_colors = (1<<((image.flags&PIXMASK)+1));
#ifdef DBG_GIF
DebugPrint(_T("Image has color table, %d colors\n"), gif_colors);
#endif // DBG_GIF
if(!GIFREAD(gif_cmap,gif_colors*3)) {
#ifdef DBG_GIF
DebugPrint(_T("<ERROR READING COLOR MAP>\n"));
#endif // DBG_GIF
TRUNCOUT:
badGIFReason = GIF_INVALID_FILE;
if(s)
delete s;
return NULL;
}
}
assert(fbi);
// if (!fbi) return(-5);
//-- Create a storage for this bitmap ------------------------------------
s = BMMCreateStorage(manager,storageType);
if(!s)
return NULL;
if(storageType != BMM_PALETTED)
fbi->SetFlags(MAP_HAS_ALPHA);
if (s->Allocate(fbi,manager,BMM_OPEN_R)==0) {
if(s)
delete s;
return NULL;
}
loadStorage = s;
int GDResult = GIFDecoder(image.w);
switch(GDResult)
{
case READ_ERROR:
#ifdef DBG_GIF
DebugPrint(_T("<READ_ERROR>\n"));
#endif // DBG_GIF
goto TRUNCOUT;
case BAD_CODE_SIZE:
#ifdef DBG_GIF
DebugPrint(_T("<BAD_CODE_SIZE>\n"));
#endif // DBG_GIF
goto TRUNCOUT;
case OUT_OF_MEMORY:
#ifdef DBG_GIF
DebugPrint(_T("<OUT_OF_MEMORY>\n"));
#endif // DBG_GIF
badGIFReason = GIF_OUT_OF_MEMORY;
delete s;
return NULL;
default:
break;
}
if(storageType == BMM_PALETTED) {
// The load went OK! Make the color palette 64 bits and stuff it into the storage
PixelBuf48 palette(256);
BMM_Color_48 *palout = palette.Ptr();
BMM_Color_24 *palin = &gif_cmap[0];
for(int i = 0; i < gif_colors; ++i,++palin,++palout) {
palout->r = (USHORT)palin->r << 8;
palout->g = (USHORT)palin->g << 8;
palout->b = (USHORT)palin->b << 8;
}
s->SetPalette(0, gif_colors, palette.Ptr());
}
return s;
}
示例3: file
//.........这里部分代码省略.........
if (b) free(b);
if (p) free(p);
if (rgb) free(rgb);
if (pal) free(pal);
return NULL;
}
switch(bmi.biBitCount)
{
case 4:
//-- Read 4 bit Palette ------------------------------------
if (!bmi.biClrUsed)
bmi.biClrUsed = 16;
rgb = (RGBQUAD *)malloc(bmi.biClrUsed * sizeof(RGBQUAD));
if (!rgb)
goto memory_error_out;
pal = (BMM_Color_48 *)malloc(bmi.biClrUsed * sizeof(BMM_Color_48));
if (!pal)
goto memory_error_out;
if (fread(rgb,sizeof(RGBQUAD),bmi.biClrUsed,file.stream) != bmi.biClrUsed)
goto io_error_out;
for (j = 0; j < (int)bmi.biClrUsed; j++)
{
pal[j].r = rgb[j].rgbRed << 8;
pal[j].g = rgb[j].rgbGreen << 8;
pal[j].b = rgb[j].rgbBlue << 8;
}
s->SetPalette(0,bmi.biClrUsed,pal);
free(pal);
free(rgb);
pal = NULL;
rgb = NULL;
//-- Read Image (4 Bits) -----------------------------
w = fbi->Width();
wb = ( ((fbi->Width()+1)/2)+ 3) & ~3; // width must be multiple of 4
h = fbi->Height() - 1;
p = (BYTE *)malloc(wb);
b4 = (BYTE *)malloc(w);
if (!p || !b4)
goto memory_error_out;
do
{
pixels = fread(p,1,wb,file.stream);
if (pixels != wb && pixels != 0)
goto io_error_out;
if (pixels)
{
// -- the 4bit buffer p has two pixels per byte.
// -- convert it to 8 bit buffer b8 that has one pixel per byte
for(j=0;j<w;j++)
{
b4[j] = (j%2) ? (p[j/2] & 0x0f) : (p[j/2] >> 4);