Dear friends, I need your help.
I need to send .bmp file to another process (dialog box) and display it there, using MMF(Memory Mapped File)
But the problem is that image displays in reversed colors and upside down.
In first application I open picture from HDD and link it to the named MMF "Gigabyte_picture"
HANDLE hFile = CreateFile("123.bmp", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, "Gigabyte_picture");
In second application I open mapped bmp file and at the end I display m_HBitmap on the static component, using SendMessage function.
HANDLE hMappedFile = OpenFileMapping(FILE_MAP_READ, FALSE, "Gigabyte_picture");
PBYTE pbData = (PBYTE) MapViewOfFile(hMappedFile, FILE_MAP_READ, 0, 0, 0);
BITMAPINFO bmpInfo = { 0 };
LONG lBmpSize = 60608; // size of the bmp file in bytes
bmpInfo.bmiHeader.biBitCount = 32;
bmpInfo.bmiHeader.biHeight = 174;
bmpInfo.bmiHeader.biWidth = 87;
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biSizeImage = lBmpSize;
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
UINT * pPixels = 0;
HDC hDC = CreateCompatibleDC(NULL);
HBITMAP m_HBitmap = CreateDIBSection(hDC, &bmpInfo, DIB_RGB_COLORS, (void **)& pPixels, NULL, 0);
SetBitmapBits(m_HBitmap, lBmpSize, pbData);
SendMessage(gStaticBox, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)m_HBitmap);
/////////////
HWND gStaticBox = CreateWindowEx(0, "STATIC","",
SS_CENTERIMAGE | SS_REALSIZEIMAGE | SS_BITMAP | WS_CHILD | WS_VISIBLE,
10,10,380, 380, myDialog, (HMENU)-1,NULL,NULL);