关于StretchDIBits [英] About StretchDIBits

查看:112
本文介绍了关于StretchDIBits的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近已阅读有关如何通过操作像素来显示BMP的代码,I
不了解有关Parameter(lpBits)的代码.代码如下:

**
lpBuf =(LPBYTE)GlobalAlloc(GPTR,sizeof(BITMAPINFO)+ 255 * sizeof(RGBQUAD)+ 512 * 512 + 32 * 32 * 5 );
lpDIB =(LPBITMAPINFO)lpBuf;
lpRGB =(RGBQUAD *)(lpBuf + sizeof(BITMAPINFOHEADER));
lpScreen = lpBuf + sizeof(BITMAPINFOHEADER)+ 255 * sizeof(RGBQUAD);
为(int i = 0; i< 5; i ++)
lpChr [i] = lpScreen + 512 * 512 + 32 * 32 * i;

miHeader.biBitCount = 8;
lpRGB [0] .rgbRed = 0;
lpRGB [0] .rgbGreen = 0;
lpRGB [0] .rgbBlue = 0;
lpRGB [1] .rgbRed = 128;
lpRGB [1] .rgbGreen = 128;
lpRGB [1] .rgbBlue = 128;
***

通过操作lpBuf( 32 * 32 * 5 ),BMP图片已更改,
我想知道lpBuf( 32 * 32 * 5 )

Recently Having Readen Code About How to Show BMP By Operating Pixel,I
don''t understand codes about Parameter(lpBits).Code As Below:

**
lpBuf=(LPBYTE)GlobalAlloc(GPTR,sizeof(BITMAPINFO)+255*sizeof(RGBQUAD)+512*512+32*32*5);
lpDIB=(LPBITMAPINFO)lpBuf;
lpRGB=(RGBQUAD*)(lpBuf+sizeof(BITMAPINFOHEADER));
lpScreen=lpBuf+sizeof(BITMAPINFOHEADER)+255*sizeof(RGBQUAD);
for (int i=0;i<5;i++)
lpChr[i]=lpScreen+512*512+32*32*i;

miHeader.biBitCount=8;
lpRGB[0].rgbRed=0;
lpRGB[0].rgbGreen=0;
lpRGB[0].rgbBlue=0;
lpRGB[1].rgbRed=128;
lpRGB[1].rgbGreen=128;
lpRGB[1].rgbBlue=128;
***

By Operating lpBuf(32*32*5),BMP Picture Changed,
I Want to know Funciton of lpBuf(32*32*5)

推荐答案

您正在分配的函数图像的内存.为此,您需要为每个像素和该图像所需的颜色深度分配内存.那就是32 * 32 * 5的作用.
You''re allocating memory for the image. In order to do that, you need to allocate memory for each pixel and the desired color depth of that image. That''s what the 32*32*5 does.


上图:
>为此,您需要为每个像素分配内存
>以及该图像的所需颜色深度.那就是32 * 32 * 5的作用.
您能告诉我该图像(32 * 32?)的深度是5吗?
To Above:
>In order to do that, you need to allocate memory for each pixel
> and the desired color depth of that image. That''s what the 32*32*5 does.
Could You Tell Me How Much Is That Image(32*32?) and The depth Is 5?


从上下文中理解为什么不是很容易,但是32 * 32 * 5看起来像是在位图之后分配了额外的内存以用作其他功能.从变量名来看,我猜想它是用于5 32 * 32个字符"的.

512 * 512将是使用8位调色板的位图本身的大小.

255 * sizeof(RGBQUAD)是调色板的内存-BITMAPINFO结构包含第一个RGBQUAD,这就是为什么255而不是256的原因.
It isn''t very easy to understand why from the context, but the 32*32*5 looks like it is allocating extra memory after the bitmap for use as something else. From the variable name, I would guess it is for 5 32*32 "characters".

The 512*512 will be the size of the bitmap itself, using a 8-bit palette.

255*sizeof(RGBQUAD) is the memory for the palette - the BITMAPINFO structure contains the first RGBQUAD, which is why the 255 instead of 256.


这篇关于关于StretchDIBits的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆