Click here to Skip to main content
15,909,518 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help with classes and threads Pin
Blake Miller30-Jun-00 18:12
Blake Miller30-Jun-00 18:12 
GeneralRe: Help with classes and threads Pin
Blake Miller30-Jun-00 18:15
Blake Miller30-Jun-00 18:15 
GeneralProblem with cascaded controls Pin
Lea Johnson29-Jun-00 18:21
Lea Johnson29-Jun-00 18:21 
GeneralRe: Problem with cascaded controls Pin
Sam Hobbs29-Jun-00 20:14
Sam Hobbs29-Jun-00 20:14 
GeneralZ-order of children Pin
Sam Hobbs29-Jun-00 17:54
Sam Hobbs29-Jun-00 17:54 
GeneralRe: Z-order of children Pin
Lea Johnson29-Jun-00 18:32
Lea Johnson29-Jun-00 18:32 
GeneralRe: Z-order of children Pin
Sam Hobbs29-Jun-00 20:01
Sam Hobbs29-Jun-00 20:01 
GeneralBug in my BMP-routine... Pin
Christoph Rupp29-Jun-00 11:06
sussChristoph Rupp29-Jun-00 11:06 
Hi all,

i have a problem with a function which writes a DIB to a BMP file. The strange thing is that it works with small pictures but fails with big ones
(it messes up the dimensions...)

The raw bitmap data is saved in a 32 bit format, so i have to convert it to 24 bit first. Here is the code...

BITMAPFILEHEADER bfh;
BITMAPINFOHEADER bih;

unsigned char *data=(unsigned char*)malloc(3*m_nDataBr*m_nDataHo); // for the 24 bit data
unsigned char *p=(unsigned char*)m_pdwData; // this is the 32 bit data
for (int i=0, j=0; i<4*m_nDataBr*m_nDataHo; i++) {
data[j++]=p[i++];
data[j++]=p[i++];
data[j++]=p[i++];
}

// Initialize all structures
memset(&bfh, 0, sizeof(BITMAPFILEHEADER));
memset(&bih, 0, sizeof(BITMAPINFOHEADER));
bih.biSize=sizeof(bih);
bih.biBitCount=24;
bih.biHeight=m_nDataHo;
bih.biWidth=m_nDataBr;
bih.biPlanes=1;
bih.biCompression=BI_RGB;

// Fill in the Bitmap File Header
bfh.bfType=((WORD)('M'<<8)|'B');

// Calculate the size of the bitmap including the palette (which should be empty)
bfh.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+m_nDataHo*m_nDataBr*3;
bfh.bfReserved1=bfh.bfReserved2=0;

// Offset to actual bits is after palette
bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);

ASSERT(bfh.bfSize>sizeof(BITMAPFILEHEADER));

// Write the results
fwrite(&bfh, sizeof(BITMAPFILEHEADER), 1, f);
fwrite(&bih, sizeof(BITMAPINFOHEADER), 1, f);
fwrite(data, m_nDataHo*m_nDataBr*3, 1, f);

I really don't know what i am doing wrong here... if anybody could help me i really would be glad.

Chris
GeneralRe: Bug in my BMP-routine... Pin
Paolo Messina30-Jun-00 8:10
professionalPaolo Messina30-Jun-00 8:10 
GeneralRe: Bug in my BMP-routine... Pin
Christoph Rupp30-Jun-00 21:20
sussChristoph Rupp30-Jun-00 21:20 
GeneralRe: Bug in my BMP-routine... Pin
Paolo Messina1-Jul-00 4:30
professionalPaolo Messina1-Jul-00 4:30 
GeneralRe: Bug in my BMP-routine... Pin
Paolo Messina1-Jul-00 4:50
professionalPaolo Messina1-Jul-00 4:50 
GeneralRe: Bug in my BMP-routine... thanks, Paolo Pin
Christoph Rupp1-Jul-00 22:51
sussChristoph Rupp1-Jul-00 22:51 
GeneralImage library (Re: Bug in my BMP-routine... thanks, Paolo) Pin
Uwe Keim2-Jul-00 21:30
sitebuilderUwe Keim2-Jul-00 21:30 
GeneralInterface Pin
Member 375684729-Jun-00 9:04
Member 375684729-Jun-00 9:04 
GeneralCEdit vs CStatic Pin
Paul Galla29-Jun-00 6:37
sussPaul Galla29-Jun-00 6:37 
GeneralRe: CEdit vs CStatic Pin
Mike Dunn29-Jun-00 7:48
Mike Dunn29-Jun-00 7:48 
GeneralResuming FTP / HTTP downloads... Pin
xtsea29-Jun-00 4:25
xtsea29-Jun-00 4:25 
QuestionHow to check a socket is disconnected Pin
Stefan29-Jun-00 3:23
Stefan29-Jun-00 3:23 
AnswerRe: How to check a socket is disconnected Pin
Yaron29-Jun-00 3:43
Yaron29-Jun-00 3:43 
GeneralRe: How to check a socket is disconnected Pin
RamiBuchnik29-Jun-00 4:31
RamiBuchnik29-Jun-00 4:31 
QuestionDebug Assertion Failed ? Pin
kasjhdfkjhfj29-Jun-00 3:12
kasjhdfkjhfj29-Jun-00 3:12 
AnswerRe: Debug Assertion Failed ? Pin
Christoph Rupp29-Jun-00 11:03
sussChristoph Rupp29-Jun-00 11:03 
GeneralRe: Debug Assertion Failed ? Thanks Chris Pin
kasjhdfkjhfj30-Jun-00 3:41
kasjhdfkjhfj30-Jun-00 3:41 
GeneralMessage handler Pin
Bjorn29-Jun-00 1:44
Bjorn29-Jun-00 1:44 

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.