本文整理汇总了C++中BitmapStorage类的典型用法代码示例。如果您正苦于以下问题:C++ BitmapStorage类的具体用法?C++ BitmapStorage怎么用?C++ BitmapStorage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BitmapStorage类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: palette
/* Read an PNG file, returning the storage where it's located */
BitmapStorage *
BitmapIO_PNG::ReadPNGFile(BitmapInfo *fbi, BitmapManager *manager)
{
BitmapStorage *storage = NULL;
unsigned char magic_numbers[8];
if((istream=_tfopen(fbi->Name(), _T("rb")))==NULL)
return NULL;
// grab the first 8 bytes for testing
if (fread(magic_numbers, 1, 8, istream) != 8) {
fclose(istream);
return NULL;
} else
rewind(istream);
// Make sure we're a png file
if (!png_check_sig(magic_numbers, 8)) {
fclose(istream);
return NULL;
}
png = png_create_read_struct (PNG_VERSION, (void *) this, error_func, warning_func);
if (setjmp(png->jmpbuf)) {
if (info)
for (png_uint_32 i = 0; i < info->height; i++)
if (row_pointers[i]) free(row_pointers[i]);
if (row_pointers) {
free(row_pointers);
row_pointers = NULL;
}
if (storage) {
delete storage;
storage = NULL;
}
fclose(istream);
png_destroy_read_struct (&png, &info, NULL);
return NULL;
}
info = png_create_info_struct(png);
png_init_io(png, istream);
png_read_info(png, info);
fbi->SetWidth((WORD)info->width);
fbi->SetHeight((WORD)info->height);
if (info->valid & PNG_INFO_gAMA)
fbi->SetGamma(info->gamma);
// else
// fbi->SetGamma (1.0f);
if (info->valid & PNG_INFO_pHYs)
fbi->SetAspect((float)info->x_pixels_per_unit / (float)info->y_pixels_per_unit);
else
fbi->SetAspect(1.0f);
fbi->SetFlags(0);
/* expand grayscale images to the full 8 bits */
/* expand images with transparency to full alpha channels */
/* I'm going to ignore lineart and just expand it to 8 bits */
if ((info->color_type == PNG_COLOR_TYPE_PALETTE && info->bit_depth < 8) ||
(info->color_type == PNG_COLOR_TYPE_GRAY && info->bit_depth < 8) ||
(info->valid & PNG_INFO_tRNS))
png_set_expand(png);
int number_passes = 1;
if (info->interlace_type)
number_passes = png_set_interlace_handling(png);
if (info->bit_depth == 16)
png_set_swap(png);
png_read_update_info(png, info);
int bmtype = BMM_NO_TYPE;
if (info->bit_depth == 1) {
bmtype = BMM_LINE_ART;
} else {
switch(info->color_type) {
case PNG_COLOR_TYPE_PALETTE:
bmtype = BMM_PALETTED;
break;
case PNG_COLOR_TYPE_RGB:
case PNG_COLOR_TYPE_RGB_ALPHA:
switch(info->bit_depth) {
case 2:
case 4:
// Not allowed
break;
case 8:
bmtype = BMM_TRUE_32; // zero alpha for those that don't have it
break;
case 16:
bmtype = BMM_TRUE_64;
break;
}
//.........这里部分代码省略.........
示例3: file
//FIXME
BitmapStorage*
BitmapIO_CIN::Load(BitmapInfo* bmi, Bitmap* bm, unsigned short* status)
{
BitmapStorage* bms = NULL;
File file(bmi->Name(), _T("rb"));
*status = BMMRES_SUCCESS;
if (!file.mStream) {
*status = ProcessImageIOError(bmi, GetResIDCaption(IDS_CIN_File_Open_Error));
return NULL;
}
mStream = file.mStream;
if (openMode != BMM_NOT_OPEN) {
*status = ProcessImageIOError(bmi, GetResIDCaption(IDS_CIN_Internal_Error));
return NULL;
}
CineonFile cineonImage(mStream);
if (cineonImage.VerifyHeader() == FALSE) {
*status = ProcessImageIOError(bmi, GetResIDCaption(IDS_CIN_Invalid_Header_Error));
return NULL;
}
if (!cineonImage.IsSupported()) {
*status = ProcessImageIOError(bmi, GetResIDCaption(IDS_CIN_Unsupported_File_Error));
return NULL;
}
unsigned int pixelsPL = cineonImage.GetPixelsPerLine();
unsigned int linesPI = cineonImage.GetLinesPerImage();
bmi->SetWidth(pixelsPL);
bmi->SetHeight(linesPI);
// bmi->SetGamma(cineonImage.GetImageGamma());
// bmi->SetAspect();
bmi->SetFirstFrame(0);
bmi->SetLastFrame(0);
// bmi->SetFlags(MAP_NOFLAGS);
bms = BMMCreateStorage(bm->Manager(), BMM_TRUE_64);
if (!bms) {
*status = ProcessImageIOError(bmi, GetResIDCaption(IDS_CIN_Internal_Error));
return NULL;
}
if (!(bms->Allocate(bmi, bm->Manager(), BMM_OPEN_R))) {
*status = ProcessImageIOError(bmi, GetResIDCaption(IDS_CIN_Memory_Error));
delete bms;
bms = NULL;
return NULL;
}
BMM_Color_64* scanLine = (BMM_Color_64*) calloc(pixelsPL, sizeof(BMM_Color_64));
if (!scanLine) {
*status = ProcessImageIOError(bmi, GetResIDCaption(IDS_CIN_Memory_Error));
if (bms) { delete bms; bms = NULL; }
return NULL;
}
if (!cineonImage.SetLUTs(10, (float) mUserData.mRefWhite, (float) mUserData.mRefBlack)) {
*status = ProcessImageIOError(bmi, GetResIDCaption(IDS_CIN_Memory_Error));
if (bms) { delete bms; bms = NULL; }
return NULL;
}
for (unsigned int cnt = 0; cnt < linesPI; cnt++) {
// 4 WORD Channels
if (!cineonImage.GetScanLine((unsigned short*)scanLine, cnt, pixelsPL)) {
*status = ProcessImageIOError(bmi, GetResIDCaption(IDS_CIN_File_IO_Error));
if (bms) { delete bms; bms = NULL; }
if (scanLine) { free(scanLine); scanLine = NULL; }
return NULL;
}
// test colors ~ 5sec 1828x1332
/*
float r1 = ((float) cnt) / ((float) linesPI);
for (unsigned int i = 0; i < pixelsPL; i++) {
float r2 = ((float) i) / ((float) pixelsPL);
scanLine[i].r = (int) (65535.f * r1);
scanLine[i].g = (int) (65535.f * r2);
scanLine[i].b = (int) (65535.f * (r1 * r2));
scanLine[i].a = 0; //CIN has no alpha
}
*/
if (!bms->PutPixels(0, cnt, pixelsPL, scanLine)) {
*status = ProcessImageIOError(bmi, GetResIDCaption(IDS_CIN_Internal_Error));
if (bms) { delete bms; bms = NULL; }
if (scanLine) { free(scanLine); scanLine = NULL; }
return NULL;
}
}
if (scanLine) { free(scanLine); scanLine = NULL; }
openMode = BMM_OPEN_R;
//.........这里部分代码省略.........
示例4: file
BitmapStorage *BitmapIO_BMP::Load(BitmapInfo *fbi, Bitmap *map, BMMRES *status)
{
RGBQUAD *rgb = NULL;
BMM_Color_48 *pal = NULL;
BitmapStorage *s = NULL;
BMM_Color_64 *b = NULL;
BYTE *p = NULL;
BYTE *b8 = NULL;
BYTE *b4 = NULL;
INT_PTR pixels = 0;
int rows = 0;
int w = 0;
int wb = 0;
int h = 0;
int j;
//-- Initialize Status Optimistically
*status = BMMRES_SUCCESS;
//-- Make sure nothing weird is going on
if(openMode != BMM_NOT_OPEN) {
*status = ProcessImageIOError(fbi,BMMRES_INTERNALERROR);
return NULL;
}
//-- Open BMP File -----------------------------------
File file(fbi->Name(), _T("rb"));
if (!file.stream) {
*status = ProcessImageIOError(fbi);
return(NULL);
}
//-- Read File Header --------------------------------
if (!ReadBimpHeader(file.stream)) {
*status = ProcessImageIOError(fbi,BMMRES_BADFILEHEADER);
return (NULL);
}
//-- Update Bitmap Info ------------------------------
fbi->SetWidth( (WORD)bmi.biWidth );
fbi->SetHeight((WORD)bmi.biHeight);
if ((bmi.biBitCount != 32 && bmi.biBitCount != 24 && bmi.biBitCount != 8 && bmi.biBitCount != 4) ||
bmi.biCompression != BI_RGB) {
*status = ProcessImageIOError(fbi,GetString(IDS_UNSUPPORTED));
return(NULL);
}
// fbi->SetGamma(1.0f);
fbi->SetAspect(1.0f);
switch(bmi.biBitCount)
{
case 32:
fbi->SetType(BMM_TRUE_32);
// [[email protected]/19/2008] We need to set this flag so that the alpha storage will be created in BMMCreateStorage
fbi->SetFlags(MAP_HAS_ALPHA);
break;
case 24:
fbi->SetType(BMM_TRUE_24);
break;
case 8:
case 4:
//-- We don't have a 4 bit bitmap storage anyway.
//-- So force 4 bit to 8 bit
fbi->SetType(BMM_PALETTED);
break;
}
fbi->SetFirstFrame(0);
fbi->SetLastFrame(0);
//-- Create Image Storage ----------------------------
switch(bmi.biBitCount)
{
case 32:
s = BMMCreateStorage(map->Manager(), BMM_TRUE_32);
break;
case 24:
s = BMMCreateStorage(map->Manager(),BMM_TRUE_32);
break;
case 8:
case 4:
//.........这里部分代码省略.........
示例5: file
BitmapStorage *BitmapIO_YUV::Load(BitmapInfo *fbi, Bitmap *map, BMMRES *status) {
unsigned char *yuvbuf = NULL;
BMM_Color_64 *rgbbuf = NULL;
BitmapStorage *s = NULL;
//-- Initialize Status Optimistically
*status = BMMRES_SUCCESS;
//-- Make sure nothing weird is going on
if(openMode != BMM_NOT_OPEN) {
*status = ProcessImageIOError(fbi,BMMRES_INTERNALERROR);
return NULL;
}
//-- Update Bitmap Info
*status = GetImageInfo(fbi);
if (*status != BMMRES_SUCCESS)
return(NULL);
//-- Open YUV File -----------------------------------
File file(fbi->Name(), _T("rb"));
inStream = file.stream;
if (inStream == NULL) {
*status = ProcessImageIOError(fbi);
return NULL;
}
//-- Create Image Storage ----------------------------
s = BMMCreateStorage(map->Manager(),BMM_TRUE_32);
if(!s) {
*status = ProcessImageIOError(fbi,BMMRES_INTERNALERROR);
return NULL;
}
//-- Allocate Image Storage --------------------------
if (s->Allocate(fbi,map->Manager(),BMM_OPEN_R)==0) {
memory_error_out:
*status = ProcessImageIOError(fbi,BMMRES_MEMORYERROR);
goto bail_out;
io_error_out:
*status = ProcessImageIOError(fbi);
bail_out:
if (s)
delete s;
if (yuvbuf)
free(yuvbuf);
if (rgbbuf)
free(rgbbuf);
return NULL;
}
//-- Allocate Buffers --------------------------------
yuvbuf=(unsigned char *)malloc(fbi->Width()*2);
rgbbuf=(BMM_Color_64 *)malloc(fbi->Width()*sizeof(BMM_Color_64));
if(!yuvbuf || !rgbbuf)
goto memory_error_out;
//-- Read Image
INT_PTR pixels = fbi->Width() * fbi->Height();
int rows = 0;
while (pixels) {
pixels = fread(yuvbuf,2,fbi->Width(),inStream);
if (pixels != fbi->Width() && pixels != 0) {
goto io_error_out;
}
if (pixels) {
YUVtoRGB(rgbbuf,yuvbuf,fbi->Width());
if (s->PutPixels(0,rows,fbi->Width(),rgbbuf)!=1)
goto io_error_out;
rows++;
if (rows>fbi->Height()) break;
}
//-- Progress Report
if (fbi->GetUpdateWindow())
SendMessage(fbi->GetUpdateWindow(),BMM_PROGRESS,rows,fbi->Height());
}
if (yuvbuf)
free(yuvbuf);
if (rgbbuf)
free(rgbbuf);
//-- Set the storage's BitmapInfo
//.........这里部分代码省略.........
示例6: LoadIBitmap
IBitmap IGraphicsLice::LoadIBitmap(int ID, const char* name, int nStates)
{
LICE_IBitmap* lb = s_bitmapCache.Find(ID);
if (!lb)
{
lb = OSLoadBitmap(ID, name);
bool imgResourceFound = (lb);
assert(imgResourceFound); // Protect against typos in resource.h and .rc files.
s_bitmapCache.Add(lb, ID);
}
return IBitmap(lb, lb->getWidth(), lb->getHeight(), nStates);
}
示例7: LoadIBitmap
IBitmap IGraphics::LoadIBitmap(int ID, const char* name, int nStates, bool framesAreHoriztonal)
{
LICE_IBitmap* lb = s_bitmapCache.Find(ID);
if (!lb)
{
lb = OSLoadBitmap(ID, name);
#ifndef NDEBUG
bool imgResourceFound = lb;
#endif
assert(imgResourceFound); // Protect against typos in resource.h and .rc files.
s_bitmapCache.Add(lb, ID);
}
return IBitmap(lb, lb->getWidth(), lb->getHeight(), nStates, framesAreHoriztonal);
}
示例8: ReleaseBitmap
void IGraphics::ReleaseBitmap(IBitmap* pBitmap)
{
s_bitmapCache.Remove((LICE_IBitmap*)pBitmap->mData);
}
示例9: RetainBitmap
void IGraphics::RetainBitmap(IBitmap* pBitmap)
{
s_bitmapCache.Add((LICE_IBitmap*)pBitmap->mData);
}
示例10: FindBitmap
LICE_IBitmap* IGraphics::FindBitmap(int ID)
{
return s_bitmapCache.Find(ID);
}
示例11: RetainBitmap
void IGraphics::RetainBitmap(IBitmap* pBitmap, int ID = -1)
{
s_bitmapCache.Add((LICE_IBitmap*)pBitmap->mData, ID);
}