Click here to Skip to main content
15,844,673 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: c libraries needed to deal with bitmaps Pin
phil.o14-Mar-20 9:37
professionalphil.o14-Mar-20 9:37 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan14-Mar-20 10:27
mveRichard MacCutchan14-Mar-20 10:27 
GeneralRe: c libraries needed to deal with bitmaps Pin
phil.o14-Mar-20 10:34
professionalphil.o14-Mar-20 10:34 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan14-Mar-20 22:58
mveRichard MacCutchan14-Mar-20 22:58 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru12-Mar-20 1:35
Calin Negru12-Mar-20 1:35 
GeneralRe: c libraries needed to deal with bitmaps Pin
Victor Nijegorodov11-Mar-20 23:45
Victor Nijegorodov11-Mar-20 23:45 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru12-Mar-20 1:43
Calin Negru12-Mar-20 1:43 
AnswerRe: c libraries needed to deal with bitmaps Pin
leon de boer12-Mar-20 6:31
leon de boer12-Mar-20 6:31 
You are messing around with stuff you do not have to do on Windows and there is no advantage in doing what you are doing other than learning.

You can load a bitmap with one line of code using the API LoadBitmap()

LoadBitmapA function (winuser.h) - Win32 apps | Microsoft Docs[^]

One line of code will load it for you and it doesn't care what the bitmap format is.
HBITMAP MyBmp = LoadBitmap(0, "Yourbitmapname.bmp");

Once you have a HBITMAP (handle to a bitmap) in Windows you can basically do everything with it.
If you want the details from the bitmap once you have it loaded you just ask windows to extract them for you
So with my handle above I can extract the header with 2 lines of code the 3rd line is just to throw the details out (it assumes you are doing a console app).
BITMAP bm;
GetObject(MyBmp, sizeof(bm), &bm);
printf("Bitmap is wth: %u ht: %u bitdepth: %u\r\n", bm.bmWidth, bm.bmHeight, bm.bmBitsPixel);

So I can load the bitmap and extract the header with 3 lines in absolute safety.
If you are messing around with the actual header etc in Windows you are doing it all wrong Smile | :)
The only time you might play with a BMP file header is writing a BMP in a specific format.

That is why there is no need for libraries on Windows to handle bitmaps. Now JPEGS are a little trickier it's about 20 lines of code to get windows to load one of those most of the issue the filename has to be in UNICODE. Let me know if you need to know how to do it.
In vino veritas


modified 12-Mar-20 11:48am.

GeneralRe: c libraries needed to deal with bitmaps Pin
Victor Nijegorodov12-Mar-20 9:39
Victor Nijegorodov12-Mar-20 9:39 
GeneralRe: c libraries needed to deal with bitmaps Pin
leon de boer12-Mar-20 14:19
leon de boer12-Mar-20 14:19 
QuestionWhat`s a palette in the parsing a bitmap context Pin
Calin Negru10-Mar-20 6:00
Calin Negru10-Mar-20 6:00 
AnswerRe: What`s a palette in the parsing a bitmap context Pin
phil.o10-Mar-20 6:16
professionalphil.o10-Mar-20 6:16 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
Calin Negru10-Mar-20 7:34
Calin Negru10-Mar-20 7:34 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
phil.o10-Mar-20 8:05
professionalphil.o10-Mar-20 8:05 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
harold aptroot10-Mar-20 17:31
harold aptroot10-Mar-20 17:31 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
phil.o10-Mar-20 20:27
professionalphil.o10-Mar-20 20:27 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
Calin Negru10-Mar-20 22:06
Calin Negru10-Mar-20 22:06 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
phil.o10-Mar-20 22:11
professionalphil.o10-Mar-20 22:11 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
Calin Negru10-Mar-20 22:30
Calin Negru10-Mar-20 22:30 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
phil.o10-Mar-20 22:46
professionalphil.o10-Mar-20 22:46 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
Calin Negru11-Mar-20 8:32
Calin Negru11-Mar-20 8:32 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
leon de boer12-Mar-20 6:15
leon de boer12-Mar-20 6:15 
QuestionHaving issues with the cin.getline() function in C++ Pin
Member 147670008-Mar-20 15:29
Member 147670008-Mar-20 15:29 
AnswerRe: Having issues with the cin.getline() function in C++ Pin
k50548-Mar-20 16:37
mvek50548-Mar-20 16:37 
GeneralRe: Having issues with the cin.getline() function in C++ Pin
Member 147670009-Mar-20 11:55
Member 147670009-Mar-20 11:55 

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.