当前位置: 首页>>代码示例>>C++>>正文


C++ BitmapStorage::PutIndexPixels方法代码示例

本文整理汇总了C++中BitmapStorage::PutIndexPixels方法的典型用法代码示例。如果您正苦于以下问题:C++ BitmapStorage::PutIndexPixels方法的具体用法?C++ BitmapStorage::PutIndexPixels怎么用?C++ BitmapStorage::PutIndexPixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitmapStorage的用法示例。


在下文中一共展示了BitmapStorage::PutIndexPixels方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: palette


//.........这里部分代码省略.........
        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;
					}
				}
				storage->PutIndexPixels(0, iy, info->width, pixels);
			}
			free(pixels);
		}
		// Now the palette
		PixelBuf48 palette(256);
		BMM_Color_48 *palout = palette.Ptr();
开发者ID:2asoft,项目名称:xray,代码行数:67,代码来源:png.cpp

示例2: file


//.........这里部分代码省略.........
    
         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);
               }
               s->PutIndexPixels(0,(h - rows),w,b4);
               rows++;
               if (rows>h) break;
            }

            //-- Progress Report
         
            if (fbi->GetUpdateWindow())
               SendMessage(fbi->GetUpdateWindow(),BMM_PROGRESS,rows,h);

         } while (pixels);
         break;
      
      case 8:  
         
         //-- Read 8 bitPalette ------------------------------------

         if (!bmi.biClrUsed) 
            bmi.biClrUsed = 256;
         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;
         }
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:67,代码来源:bmp.cpp


注:本文中的BitmapStorage::PutIndexPixels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。