Hi, I have been trying to learn windows graphics properly, so I can do more than just using brushes & stuff. The main thing I have been trying to do, is use CreateDIBSection, I think this isn't actually needed in loading bitmaps though and is just used to either create one from scratch, or get access to the bits in the bitmap. I may still want to use this function though as it could still be useful. What I mainly want to do (right now) though, is be able to load a bitmap with CreateFie(), and then, use the bitmap with bltbit etc. Also I need to be able to add other bitmaps to the same dc? I'm thinking of a gui, where if your mouse is over something it would highlight, -ie I woud "paste" another bitmap over that part.
This is the code I've got so far for CreateFile() and CreateDIBSection.
Code:
switch(uiMessage)
{
case WM_CREATE:
FileHandle = CreateFile(afilename,GENERIC_READ | GENERIC_WRITE,
0,NULL,OPEN_EXISTING,0,NULL);
FileMapping = CreateFileMapping(FileHandle,NULL,PAGE_READWRITE,
0,0,NULL);
//MapViewOfFile returns a void pointer
FileHeader = (BITMAPFILEHEADER*)MapViewOfFile(FileMapping,
FILE_MAP_WRITE,0,0,0);
offset = FileHeader->bfOffBits;
// outfile <<FileHeader->bfOffBits;
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
BITMAP bmp;
HDC hdc = BeginPaint(hwnd, &ps);
bm=CreateDIBSection(hdc,format,DIB_RGB_COLORS,(void**)&Bits,
FileMapping,offset);
GetObject(FileMapping, sizeof(bm), &bm);
HDC memorydc=CreateCompatibleDC(hdc);
HBITMAP oldbitmap=(HBITMAP)SelectObject(memorydc,bm+offset);
BitBlt(hdc,0,0,32,32,memorydc,0,0,SRCCOPY);
SelectObject(memorydc,oldbitmap);
DeleteDC(memorydc);
EndPaint(hwnd, &ps);
return 0;
Thanks for any help, like I said, I did want to use DIBSection, but at the end of the day I just want to be able to load/paste bitmaps, not as resources though.
ps,
C++