Click here to Skip to main content
15,881,882 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: c libraries needed to deal with bitmaps Pin
phil.o14-Mar-20 8:37
professionalphil.o14-Mar-20 8:37 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan14-Mar-20 9:27
mveRichard MacCutchan14-Mar-20 9:27 
GeneralRe: c libraries needed to deal with bitmaps Pin
phil.o14-Mar-20 9:34
professionalphil.o14-Mar-20 9:34 
GeneralRe: c libraries needed to deal with bitmaps Pin
Richard MacCutchan14-Mar-20 21:58
mveRichard MacCutchan14-Mar-20 21:58 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru12-Mar-20 0:35
Calin Negru12-Mar-20 0:35 
GeneralRe: c libraries needed to deal with bitmaps Pin
Victor Nijegorodov11-Mar-20 22:45
Victor Nijegorodov11-Mar-20 22:45 
GeneralRe: c libraries needed to deal with bitmaps Pin
Calin Negru12-Mar-20 0:43
Calin Negru12-Mar-20 0:43 
AnswerRe: c libraries needed to deal with bitmaps Pin
leon de boer12-Mar-20 5:31
leon de boer12-Mar-20 5: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 8:39
Victor Nijegorodov12-Mar-20 8:39 
GeneralRe: c libraries needed to deal with bitmaps Pin
leon de boer12-Mar-20 13:19
leon de boer12-Mar-20 13:19 
QuestionWhat`s a palette in the parsing a bitmap context Pin
Calin Negru10-Mar-20 5:00
Calin Negru10-Mar-20 5:00 
AnswerRe: What`s a palette in the parsing a bitmap context Pin
phil.o10-Mar-20 5:16
professionalphil.o10-Mar-20 5:16 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
Calin Negru10-Mar-20 6:34
Calin Negru10-Mar-20 6:34 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
phil.o10-Mar-20 7:05
professionalphil.o10-Mar-20 7:05 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
harold aptroot10-Mar-20 16:31
harold aptroot10-Mar-20 16:31 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
phil.o10-Mar-20 19:27
professionalphil.o10-Mar-20 19:27 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
Calin Negru10-Mar-20 21:06
Calin Negru10-Mar-20 21:06 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
phil.o10-Mar-20 21:11
professionalphil.o10-Mar-20 21:11 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
Calin Negru10-Mar-20 21:30
Calin Negru10-Mar-20 21:30 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
phil.o10-Mar-20 21:46
professionalphil.o10-Mar-20 21:46 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
Calin Negru11-Mar-20 7:32
Calin Negru11-Mar-20 7:32 
GeneralRe: What`s a palette in the parsing a bitmap context Pin
leon de boer12-Mar-20 5:15
leon de boer12-Mar-20 5:15 
QuestionHaving issues with the cin.getline() function in C++ Pin
Member 147670008-Mar-20 14:29
Member 147670008-Mar-20 14:29 
AnswerRe: Having issues with the cin.getline() function in C++ Pin
k50548-Mar-20 15:37
mvek50548-Mar-20 15:37 
GeneralRe: Having issues with the cin.getline() function in C++ Pin
Member 147670009-Mar-20 10:55
Member 147670009-Mar-20 10: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.