本文整理汇总了C++中BitmapStorage::PutPixels方法的典型用法代码示例。如果您正苦于以下问题:C++ BitmapStorage::PutPixels方法的具体用法?C++ BitmapStorage::PutPixels怎么用?C++ BitmapStorage::PutPixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitmapStorage
的用法示例。
在下文中一共展示了BitmapStorage::PutPixels方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: palette
//.........这里部分代码省略.........
png_destroy_read_struct (&png, &info, NULL);
return NULL;
}
if(storage->Allocate(fbi, manager, BMM_OPEN_R)==0) {
delete storage;
storage = NULL;
fclose(istream);
png_destroy_read_struct (&png, &info, NULL);
return NULL;
}
row_pointers = (png_bytep *)malloc(info->height * sizeof(png_bytep));
for (png_uint_32 i = 0; i < info->height; i++)
row_pointers[i] = (png_bytep)malloc(info->rowbytes);
// now read the image
png_read_image(png, row_pointers);
switch(bmtype) {
case BMM_LINE_ART: {
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->width; ix++,l64++) {
png_uint_32 abyte = ix / 8;
png_uint_32 abit = ix % 8;
unsigned char tbyte = row_pointers[iy][abyte];
unsigned char c = tbyte & (0x80 >> abit);
l64->r = l64->g = l64->b = c ? 0xffff : 0;
l64->a = 0;
}
storage->PutPixels(0, iy, info->width, line64);
}
free(line64);
}
break;
case BMM_PALETTED: {
if (info->bit_depth == 8) {
for (png_uint_32 iy = 0; iy < info->height; iy++)
storage->PutIndexPixels(0, iy, info->width, row_pointers[iy]);
} else {
unsigned char *pixels = (unsigned char *)calloc(info->width, sizeof(unsigned char));
for (png_uint_32 iy = 0; iy < info->height; iy++) {
// now fill a row of pixels
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;
}
示例2: file
//.........这里部分代码省略.........
if (!p)
goto memory_error_out;
do
{
pixels = fread(p,1,w,file.stream);
if (pixels != w && pixels != 0)
goto io_error_out;
if (pixels)
{
s->PutIndexPixels(0,(h - rows),fbi->Width(),p);
rows++;
if (rows>h) break;
}
//-- Progress Report
if (fbi->GetUpdateWindow())
SendMessage(fbi->GetUpdateWindow(),BMM_PROGRESS,rows,h);
} while (pixels);
break;
case 24:
case 32:
{
//-- Read Image (24/32 Bits) ----------------------------
bool hasAlpha = (bmi.biBitCount == 32);
w = fbi->Width();
if(!hasAlpha) {
wb = (fbi->Width() * 3 + 3) & ~3; // width bytes must be multiple of 4
}
else {
wb = (fbi->Width() * 4);
}
h = fbi->Height() - 1;
b = (BMM_Color_64 *)malloc(fbi->Width()*sizeof(BMM_Color_64));
p = (BYTE *)malloc(wb);
if(!b || !p)
goto memory_error_out;
BYTE *ptr;
do
{
pixels = fread(p,1,wb,file.stream);
if (pixels != wb && pixels != 0)
goto io_error_out;
if (pixels)
{
ptr = p;
for (int x = 0; x < w; x++)
{
b[x].b = (WORD)((*ptr++) << 8);
b[x].g = (WORD)((*ptr++) << 8);
b[x].r = (WORD)((*ptr++) << 8);
if(hasAlpha) {
b[x].a = (WORD)((*ptr++) << 8);
}
}
if (s->PutPixels(0,(h - rows),w,b)!=1)
goto io_error_out;
rows++;
if (rows>h) break;
}
//-- Progress Report
if (fbi->GetUpdateWindow())
SendMessage(fbi->GetUpdateWindow(),BMM_PROGRESS,rows,h);
} while (pixels);
}
break;
}
//-- Clean Up ----------------------------------------
if (b) free(b);
if (p) free(p);
if (b8)free(b8);
if (b4)free(b4);
//-- Set the storage's BitmapInfo
s->bi.CopyImageInfo(fbi);
return s;
}
示例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_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
//.........这里部分代码省略.........