Click here to Skip to main content
15,898,134 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Matrix to transform a vector MA to MB Pin
CPallini28-Sep-08 21:50
mveCPallini28-Sep-08 21:50 
QuestionLoad a Bitmap from a file (char array) stored in memory? Pin
Cyrilix24-Sep-08 6:04
Cyrilix24-Sep-08 6:04 
AnswerRe: Load a Bitmap from a file (char array) stored in memory? Pin
led mike24-Sep-08 6:12
led mike24-Sep-08 6:12 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Cyrilix24-Sep-08 7:34
Cyrilix24-Sep-08 7:34 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Mark Salsbery24-Sep-08 9:44
Mark Salsbery24-Sep-08 9:44 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Cyrilix24-Sep-08 10:21
Cyrilix24-Sep-08 10:21 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Mark Salsbery24-Sep-08 10:45
Mark Salsbery24-Sep-08 10:45 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Cyrilix24-Sep-08 12:02
Cyrilix24-Sep-08 12:02 
Hi Mark,

I've got a good idea of how to do this when it comes to initially loading the Bitmap. The only other issue I have is saving the Bitmap back. My impression is that from an HBITMAP that is returned from CreateDIBSection(), we can get a BITMAP by calling GetObject() in such a manner:

HBITMAP hBmp = CreateDIBSection(...);
BITMAP bmp;
GetObject(hBmp, sizeof(bmp), &bmp);


But, the BITMAP object itself does not seem to have enough information to recreate the BITMAP file. For instance, from the MSDN documentation, it states that BITMAP has the following members:

LONG        bmType;
LONG        bmWidth;
LONG        bmHeight;
LONG        bmWidthBytes;
WORD        bmPlanes;
WORD        bmBitsPixel;
LPVOID      bmBits;


The BITMAP file specification, on the other hand, has (as your link described):

BITMAPFILEHEADER:
  WORD    bfType; 
  DWORD   bfSize; 
  WORD    bfReserved1; 
  WORD    bfReserved2; 
  DWORD   bfOffBits;

BITMAPINFO:
  RGBQUAD bmiColors[1]; 

BITMAPINFOHEADER (inside BITMAPINFO):
  DWORD  biSize; 
  LONG   biWidth; 
  LONG   biHeight; 
  WORD   biPlanes; 
  WORD   biBitCount; 
  DWORD  biCompression; 
  DWORD  biSizeImage; 
  LONG   biXPelsPerMeter; 
  LONG   biYPelsPerMeter; 
  DWORD  biClrUsed; 
  DWORD  biClrImportant;

RGBQUAD array: data that has to do with palettes

Color-index array: the raw image data itself


If you compare the two lists, it would seem like BITMAP contains enough information to recreate most of the variables in BITMAPINFOHEADER as well as the info needed for the color-index array, but what about the rest of the info? It would seem like if I'm trying to convert it back to a char array, I would have to do some fancy extrapolation myself, in addition to saving some of the info that I had when I loaded the image. I will have another careful look at all of the BITMAP related functions to see if I've missed something, but at the moment, I'm sort of stuck at this point.

Also, if I haven't mentioned it to you yet, your advice so far been much appreciated.
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Mark Salsbery24-Sep-08 12:08
Mark Salsbery24-Sep-08 12:08 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Cyrilix24-Sep-08 14:10
Cyrilix24-Sep-08 14:10 
GeneralRe: Load a Bitmap from a file (char array) stored in memory? Pin
Mark Salsbery24-Sep-08 15:05
Mark Salsbery24-Sep-08 15:05 
Questionerror LNK2019 Pin
susanne124-Sep-08 5:12
susanne124-Sep-08 5:12 
QuestionRe: error LNK2019 Pin
CPallini24-Sep-08 5:25
mveCPallini24-Sep-08 5:25 
AnswerRe: error LNK2019 Pin
Hamid_RT24-Sep-08 6:11
Hamid_RT24-Sep-08 6:11 
Questioninvalid memory allocation not throwing exception but opening Windows message box? Pin
T.T.H.24-Sep-08 5:11
T.T.H.24-Sep-08 5:11 
AnswerRe: invalid memory allocation not throwing exception but opening Windows message box? Pin
T.T.H.30-Sep-08 4:12
T.T.H.30-Sep-08 4:12 
QuestionSend a file to an eMail address "silently" Pin
Joseph Marzbani24-Sep-08 4:46
Joseph Marzbani24-Sep-08 4:46 
AnswerRe: Send a file to an eMail address "silently" Pin
Iain Clarke, Warrior Programmer24-Sep-08 4:56
Iain Clarke, Warrior Programmer24-Sep-08 4:56 
GeneralRe: Send a file to an eMail address "silently" Pin
Joseph Marzbani24-Sep-08 5:03
Joseph Marzbani24-Sep-08 5:03 
GeneralRe: Send a file to an eMail address "silently" Pin
Perspx24-Sep-08 6:14
Perspx24-Sep-08 6:14 
AnswerRe: Send a file to an eMail address "silently" Pin
Joseph Marzbani24-Sep-08 7:06
Joseph Marzbani24-Sep-08 7:06 
GeneralRe: Send a file to an eMail address "silently" Pin
Perspx24-Sep-08 7:10
Perspx24-Sep-08 7:10 
GeneralRe: Send a file to an eMail address "silently" Pin
Joseph Marzbani24-Sep-08 7:37
Joseph Marzbani24-Sep-08 7:37 
GeneralRe: Send a file to an eMail address "silently" Pin
CPallini24-Sep-08 7:21
mveCPallini24-Sep-08 7:21 
GeneralRe: Send a file to an eMail address "silently" Pin
Joseph Marzbani24-Sep-08 7:40
Joseph Marzbani24-Sep-08 7:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.