gdiplus Bitmap 转 gdi BITMAP
来源:互联网 发布:linux挂载新硬盘 编辑:程序博客网 时间:2024/05/22 10:57
1,通过GetHBITMAP()实现
在笔者的机子上,不管PixelFormat是8bit,24bit,还是32bit,通过GetHBITMAP得到的HBITMAP,永远是32bit.
通过以下方法查看BITMAP位深度:
HBitmap to BITMAP:
BITMAP bmp; ::GetObject(hbmp,sizeof(BITMAP),&bmp);
分析原因,可能是HBIMAP是DDB,与设备相关,所以图像的位深度是跟显卡的位数相关的。
2,通过LockBits()实现
LPBYTE ImgUtl::GetBitmapData(void *bmpDst){Bitmap *bitmap = (Bitmap*)bmpDst;Gdiplus::BitmapData bitmapData;Gdiplus::Rect rect(0, 0, bitmap->GetWidth(), bitmap->GetHeight());BYTE* buffer = NULL;//get the bitmap dataif(Gdiplus::Ok == bitmap->LockBits(&rect, //A rectangle structure that specifies the portion of the Bitmap to lock.Gdiplus::ImageLockModeRead, //ImageLockMode values that specifies the access level (read) for the Bitmap. bitmap->GetPixelFormat(),// PixelFormat values that specifies the data format of the Bitmap.&bitmapData //BitmapData that will contain the information about the lock operation.)){//get the length of the bitmap data in bytesint len = bitmapData.Height * abs(bitmapData.Stride);//new bufferbuffer = new BYTE[len];//copy it to an array of BYTEsmemcpy(buffer, bitmapData.Scan0, len);//cleanupbitmap->UnlockBits(&bitmapData); }return buffer;}
0 0
- gdiplus Bitmap 转 gdi BITMAP
- Opencv Mat转MFC Gdiplus::Bitmap
- CImage转换Gdiplus::Bitmap
- 数组转换为Gdiplus::Bitmap
- GDI编程之 Bitmap
- windows gdi - 保存bitmap
- GDI编程之 Bitmap
- GDI编程之 Bitmap
- 通过BYTE数组创建Gdiplus::Bitmap
- new Gdiplus::Bitmap(100,200); error C2660
- Gdiplus::Bitmap::FromStream 加载资源失败
- Gdiplus::Bitmap::FromStream 加载资源失败
- Bitmap Basics - A GDI tutorial
- Bitmap Basics - A GDI tutorial
- gdi+ Bitmap 与CBitmap HBITMAP
- Windows GDI:CDC绘制Bitmap
- GDI+ BitMap save 保存图像
- 3. GDI+ Bitmap和GDI HBITMAP互转
- 10种超经典的软件滤波方法,你值得拥有!
- Linux设置静态ip
- EditText相关
- Codeforce--414B--Mashmokh and ACM
- lianjie
- gdiplus Bitmap 转 gdi BITMAP
- USACO 93 Drainage Ditches
- 操作系统知识点
- android -- 框架 安卓应用程序插件化开发框架 -AAP Framework【开源项目】
- asp.net中HyperLinkField链接中绑定数据
- git学习 - 添加文件追踪,取消文件追踪
- Concurrency and Race Conditions
- java 图片批量上传 html5
- 黑马程序员——交通灯管理系统