Image data is someone coming, I want to show up, using the 16-bit RGB data, know width, pixel information and so on, but after the construction, show not to come out, can have a great spirit under the guidance of! ~ ~ ~
BITMAPINFO bmpinfo={0};
Bmpinfo. BmiHeader. BiPlanes=1;
Bmpinfo. BmiHeader. BiWidth=BMP. BmWidth;
Bmpinfo. BmiHeader. BiHeight=BMP. BmHeight;
Bmpinfo. BmiHeader. BiSizeImage=BMP. BmWidth * BMP bmHeight;
Bmpinfo. BmiHeader. BiSize=sizeof (BITMAPINFOHEADER);
Bmpinfo. BmiHeader. BiCompression=BI_RGB;
Bmpinfo. BmiHeader. BiBitCount=16;
Bmpinfo. BmiHeader. BiClrUsed=0;
//bmiColors this won't work,, Bmpinfo. BmiColors - & gt; RgbReserved=0; Bmpinfo. BmiColors - & gt; RgbRed=0 XFF; Bmpinfo. BmiColors - & gt; RgbGreen=0 XFF; Bmpinfo. BmiColors - & gt; RgbBlue=0 XFF; HDC HDC=pDC - & gt; GetSafeHdc ();
SetDIBitsToDevice (hDC,
0,//xDst
0,//yDst
BMP bmWidth,//cxSrc
BMP bmHeight,//cySrc
0,//xSrc
0,//ySrc
0,//from what position are displaying dib
BMP bmHeight,//scan line how much
BMP bmBits,//specified start from what is the position of dib scanning
& Bmpinfo,
DIB_RGB_COLORS);
CodePudding user response:
R=R1/32 * 256
G=G1/64 * 256
B=B1/32 * 256
Conversion is 24 bits of data
CodePudding user response:
Debugging found
SetDIBitsToDevice and there is no call to here, tip
No executable code is associated with this line. Possible causes include: the preprocessor directives or compiler/would optimizations
A face of meng force agghh==!
refer to the original poster ssg_king response: image data is someone coming, I want to show up, using a 16-bit RGB data, know width, pixel information and so on, but after the construction, show not to come out, can have a great spirit under the guidance of! ~ ~ ~ BITMAPINFO bmpinfo={0}; Bmpinfo. BmiHeader. BiPlanes=1; Bmpinfo. BmiHeader. BiWidth=BMP. BmWidth; Bmpinfo. BmiHeader. BiHeight=BMP. BmHeight; Bmpinfo. BmiHeader. BiSizeImage=BMP. BmWidth * BMP bmHeight; Bmpinfo. BmiHeader. BiSize=sizeof (BITMAPINFOHEADER); Bmpinfo. BmiHeader. BiCompression=BI_RGB; Bmpinfo. BmiHeader. BiBitCount=16; Bmpinfo. BmiHeader. BiClrUsed=0; //bmiColors this won't work,, Bmpinfo. BmiColors - & gt; RgbReserved=0; Bmpinfo. BmiColors - & gt; RgbRed=0 XFF; Bmpinfo. BmiColors - & gt; RgbGreen=0 XFF; Bmpinfo. BmiColors - & gt; RgbBlue=0 XFF; HDC HDC=pDC - & gt; GetSafeHdc (); SetDIBitsToDevice (hDC, 0,//xDst 0,//yDst BMP bmWidth,//cxSrc BMP bmHeight,//cySrc 0,//xSrc 0,//ySrc 0,//from what position are displaying dib BMP bmHeight,//scan line how much BMP bmBits,//specified start from what is the position of dib scanning & Bmpinfo, DIB_RGB_COLORS); CodePudding user response:
//the draw 16 bits BMP Void CShow256BmpDlg: : OnButton4 () { //TODO: Add your the control notification handler code here CClientDC dc (this);//device context for painting The CDC memDC; CBitmap bitmap. CBitmap bitmap1; HBITMAP HBITMAP; HBITMAP OldBitmap; DWORD len. MemDC. CreateCompatibleDC (& amp; Dc); Bitmap. LoadBitmap (IDB_BITMAP1);//16 bit // BITMAP bm={0}; Bitmap. GetBitmap (& amp; Bm); Int ImageSize=bm. BmWidthBytes * bm. BmHeight; BYTE * pImageIn=new BYTE [ImageSize]; Memset (pImageIn, 0, ImageSize); Len=bitmap. GetBitmapBits (ImageSize, pImageIn); //use: CreateDIBSection BITMAPINFO bmInfo; BmInfo. BmiHeader. BiSize=sizeof (BITMAPINFOHEADER); BmInfo. BmiHeader. BiWidth=bm. BmWidth; BmInfo. BmiHeader. BiHeight=- bm. BmHeight;//should '-'!!!!!!!!!! BmInfo. BmiHeader. BiPlanes=1; BmInfo. BmiHeader. BiBitCount=bm. BmBitsPixel;//=32 BmInfo. BmiHeader. BiCompression=BI_RGB; BmInfo. BmiHeader. BiSizeImage=ImageSize; BmInfo. BmiHeader. BiXPelsPerMeter=0; BmInfo. BmiHeader. BiYPelsPerMeter=0; BmInfo. BmiHeader. BiClrUsed=0; BmInfo. BmiHeader. BiClrImportant=0; Void * tempArray=NULL; HBitmap=: : CreateDIBSection (dc m_hDC, (BITMAPINFO *) & amp; BmInfo, DIB_RGB_COLORS, & amp; TempArray, NULL, 0); Memcpy (tempArray pImageIn, ImageSize); // OldBitmap=(HBITMAP) memDC. SelectObject (HBITMAP); Dc. BitBlt (0, 0, bm bmWidth, bm. BmHeight, & amp; MemDC, 0, 0, SRCCOPY); The delete [] pImageIn; } bitmap. LoadBitmap (IDB_BITMAP1);//16 bit CodePudding user response:
That bitmap. LoadBitmap (IDB_BITMAP1);//16 bit can also be changed to: HBITMAP hTmp=(HBITMAP) LoadImage (NULL, "16. BMP," IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); Bitmap. The Attach (hTmp); /* BmType 0 BmWidth 640 BmHeight 341 BmWidthBytes 1280 BmPlanes 1