本文介绍了如何修复(改变).jpg颜色GDI +到PixelFormat24bppRGB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下文章中:
查找包含在另一个位图中的位图

在使用LockBits功能之前,有GDI +方法可以加载位图.我们仅使用PixelFormat24bppRGB,因为那样我们希望LockBits确定位图的像素.当我们使用.bmp图像作为源时,它工作得很好.但是当我尝试使用另一种格式时,这根本不起作用.

我尝试使用GDI +加载.jpg,然后仅使用PixelFormat24bppRGB进行克隆.
没有成功.

In the following article:
Finding a Bitmap contained inside another Bitmap

There is GDI+ method to load bitmap before use of LockBits funtion. We ant to use only PixelFormat24bppRGB because then we want LockBits to determine pixels of bitmap. It works pretty well, when we use .bmp image as source. But when I try to use another format, this is not working at all.

I tried to load .jpg with GDI+ and then to make a clone with only PixelFormat24bppRGB.
With no success.

Gdiplus::Bitmap* bm = new Bitmap(L"test.jpg");
Gdiplus::Bitmap* bigBmp = bm->Clone(0, 0, bm->GetWidth(), bm->GetHeight(), PixelFormat24bppRGB);
Gdiplus::BitmapData* bigbitmapData = new BitmapData;
Gdiplus::Rect bigRect(0, 0, bigBmp->GetWidth(), bigBmp->GetHeight());
bigBmp->LockBits(&bigRect, ImageLockModeRead, PixelFormat24bppRGB, bigbitmapData);


jpg的位图已正确加载,因为我获得了正确的宽度和高度.

当我在上面的代码中使用时:


the bitmap from jpg is loaded correctly because I got correct width and height.

When I use in the above code:

Gdiplus::Bitmap* bm = new Bitmap(L"test.bmp");


(在.bmp中,我测试了24位颜色以及16位和8位两种颜色)一切正常.

我猜问题是因为.jpg中的颜色数字

如何修复PixelFormat24bppRGB的.jpg?任何的想法?请.


(where .bmp I tested both 24-bits colors and 16 and 8-bits) everything is working fine.

I guess the problem is becasue of colors number in .jpg

How to fix .jpg for PixelFormat24bppRGB? Any idea? please.

推荐答案


这篇关于如何修复(改变).jpg颜色GDI +到PixelFormat24bppRGB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 14:32