Sono sicuro che hai già controllato http://en.wikipedia.org/wiki/BMP_file_format.
Con queste informazioni in mano siamo in grado di dare una rapida BMP con:
// setup header structs bmpfile_header and bmp_dib_v3_header before this (see wiki)
// * note for a windows bitmap you want a negative height if you're starting from the top *
// * otherwise the image data is expected to go from bottom to top *
FILE * fp = fopen ("file.bmp", "wb");
fwrite(bmpfile_header, sizeof(bmpfile_header), 1, fp);
fwrite(bmp_dib_v3_header, sizeof(bmp_dib_v3_header_t), 1, fp);
for (int i = 0; i < 200; i++) {
for (int j = 0; j < 200; j++) {
fwrite(&image[j][i][2], 1, 1, fp);
fwrite(&image[j][i][1], 1, 1, fp);
fwrite(&image[j][i][0], 1, 1, fp);
}
}
fclose(fp);
Se impostare le intestazioni è un problema fatecelo sapere.
Modifica: Ho dimenticato, i file BMP si aspettano BGR invece di RGB, ho aggiornato il codice (sorpreso nessuno l'ha preso).
fonte
2009-12-07 22:34:02
Che formato di file? Quale sistema operativo o librerie stai usando? –
Sto usando Windows, semplice applicazione Visual Studio Win32. – Adam
Stai chiedendo un BITMAP GDI di Windows o un file .bmp? –