Click here to Skip to main content
15,917,600 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalfind out which ports are open on the local machine Pin
d_kilshtein6-Apr-03 4:41
d_kilshtein6-Apr-03 4:41 
GeneralCreate my own color palette. Pin
sandbird6-Apr-03 0:50
sandbird6-Apr-03 0:50 
GeneralDialog Background Pin
yashraj6-Apr-03 0:47
yashraj6-Apr-03 0:47 
GeneralRe: Dialog Background Pin
Pavel Klocek6-Apr-03 1:48
Pavel Klocek6-Apr-03 1:48 
GeneralRe: Dialog Background Pin
yashraj6-Apr-03 5:33
yashraj6-Apr-03 5:33 
GeneralRe: Dialog Background Pin
Daniel Strigl6-Apr-03 1:50
Daniel Strigl6-Apr-03 1:50 
QuestionHow to create B&W bmp's from binary data... Pin
sandbird6-Apr-03 0:45
sandbird6-Apr-03 0:45 
AnswerRe: How to create B&W bmp's from binary data... Pin
Heiko20036-Apr-03 3:14
sussHeiko20036-Apr-03 3:14 
Hi Mario,
perhaps you could use an old function I've written when I've started lerning c
(so the implementation is a little bit more complicated, than it should be)
you only have to create an array which contains your data.
for example:

int x_dim,y_dim
unsigned char* raw;
x_dim=4711; //here insert your width in x-direktion
y_dim=4711; //here insert your width in y-direktion

raw = new unsigned char[x_dim*y_dim];

for(int j=0;j<ydim;j++){
for(int="" i="0;i<xdim;i++){
" raw[i+j*xdim]="//here" you="" must="" decide="" which="" color="" your="" 0="" and="" 1="" should="" have,="" for="" example="" is="" white-="">255, 0is black->0
}

}

then call: raw2bmp(raw,"test.bmp",x_dim,y_dim); and your bitmap should be ready

Hope I could help you



void raw2bmp(unsigned char* raw_data,char* bmp_filename, int xdim, int ydim){
FILE *fp;
int i,j;

fp=fopen(bmp_filename,"wb");

i=xdim*ydim + 4*256 + 54; //Dateilaenge ermitteln

//Datei-Header schreiben

fputc(66,fp);fputc(77,fp); //Magic Number

j=i%256; fputc(j,fp); //Dateilaenge
j=(i%(256*256))/256; fputc(j,fp);
j=(i%(256*256*256))/(256*256); fputc(j,fp);
j=i/(256*256*256); fputc(j,fp);

fputc(0,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp);//4 reservierte Byts

fputc(54,fp);fputc(4,fp);fputc(0,fp);fputc(0,fp);//Zeiger auf Datenanfang

//Format-Header schreiben

fputc(40,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp);//Format-Header-Laenge

j=xdim%256; fputc(j,fp); //Bildbreite
j=(xdim%(256*256))/256; fputc(j,fp);
j=(xdim%(256*256*256))/(256*256); fputc(j,fp);
j=xdim/(256*256*256); fputc(j,fp);

j=ydim%256; fputc(j,fp); //Bildhoehe
j=(ydim%(256*256))/256; fputc(j,fp);
j=(ydim%(256*256*256))/(256*256); fputc(j,fp);
j=ydim/(256*256*256); fputc(j,fp);

fputc(1,fp);fputc(0,fp); //Anzahl der Ebenen

fputc(8,fp);fputc(0,fp); //Bits pro Pixel

fputc(0,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp); //Kompression

i=xdim*ydim;
j=i%256; fputc(j,fp); //Groesse der Pixeldaten
j=(i%(256*256))/256; fputc(j,fp);
j=(i%(256*256*256))/(256*256); fputc(j,fp);
j=i/(256*256*256); fputc(j,fp);

fputc(0,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp); //x-Auflösung(in Pixel pro Meter)

fputc(0,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp); //y-Auflösung(in Pixel pro Meter)

fputc(0,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp); //Anzahl genutzter Farben

fputc(0,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp); //Anzahl wichtiger Farben

//1kB einfuegen jedes mögliche Byte wird dreimal wiederholt und dann ein Nullbyte angefuegt
for(i=0;i<256;i++){fputc(i,fp);fputc(i,fp);fputc(i,fp);fputc(0,fp);}

//Bild an der y-Achse spiegeln: Bild faengt bei bmp links unten an.
for(j=ydim-1;j>=0;j--){
for(i=0;i
GeneralRe: How to create B&W bmp's from binary data... Pin
sandbird8-Apr-03 6:55
sandbird8-Apr-03 6:55 
GeneralQuestion about void pointer and pointer to a function. Pin
George25-Apr-03 22:06
George25-Apr-03 22:06 
GeneralRe: Question about void pointer and pointer to a function. Pin
Nitron6-Apr-03 14:18
Nitron6-Apr-03 14:18 
GeneralRe: Question about void pointer and pointer to a function. Pin
George26-Apr-03 15:17
George26-Apr-03 15:17 
GeneralQuestion about static variable in multi threads environment. Pin
George25-Apr-03 19:02
George25-Apr-03 19:02 
GeneralRe: Question about static variable in multi threads environment. Pin
Michael Dunn5-Apr-03 19:09
sitebuilderMichael Dunn5-Apr-03 19:09 
GeneralRe: Question about static variable in multi threads environment. Pin
George25-Apr-03 19:17
George25-Apr-03 19:17 
GeneralRe: Question about static variable in multi threads environment. Pin
Anders Molin6-Apr-03 3:04
professionalAnders Molin6-Apr-03 3:04 
GeneralRe: Question about static variable in multi threads environment. Pin
George26-Apr-03 3:12
George26-Apr-03 3:12 
QuestionHow to get the data bits from Image class (GDI+) Pin
Tossporn5-Apr-03 18:40
Tossporn5-Apr-03 18:40 
AnswerRe: How to get the data bits from Image class (GDI+) Pin
J. Dunlap5-Apr-03 18:46
J. Dunlap5-Apr-03 18:46 
Generalhelp with DirectX Pin
Steven M Hunt5-Apr-03 16:50
Steven M Hunt5-Apr-03 16:50 
GeneralRe: help with DirectX Pin
Philip Patrick6-Apr-03 1:43
professionalPhilip Patrick6-Apr-03 1:43 
GeneralI Fixed It! Pin
Steven M Hunt6-Apr-03 11:21
Steven M Hunt6-Apr-03 11:21 
QuestionMaking a large bitmap fit in a CDialog or CFormView? Pin
DanYELL5-Apr-03 16:24
DanYELL5-Apr-03 16:24 
AnswerRe: Making a large bitmap fit in a CDialog or CFormView? Pin
Philip Patrick6-Apr-03 1:48
professionalPhilip Patrick6-Apr-03 1:48 
GeneralOdd behavoir of ::EnumChildWindows Pin
Abin5-Apr-03 14:18
Abin5-Apr-03 14:18 

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.