c2dbmpimage-compressiondct

Blackfin. 2D DCT/IDCT (image compression) with BF537 EZ-KIT, HOW TO WRITE TO FILE (on disk) reconstructed image (Raw pixel data) from BF537 memory?


I tried this experiment with Digital Image Processing - 2D DCT/IDCT (image compression) with BF537 EZ-KIT implemented by AnalogDevices.

To mention a "resume":

Mention that when i load image into BF memory from disk with Image Viewer, or from BF memory with Image Viewer, source format is Raw Pixel Data.

BUT all I want to do in addition to this project and DON'T KNOW HOW is:

I tried to fwrite that reconstructed buffer located in memory at 0x80000 into a *.bmp file, but it seems that when i open it i receive errors like: "can't read file header; unknown file format, or file not found...";

//my code for saving/creating/writing
//    that reconstructed image = Raw pixel data from Blackfin memory  

    unsigned char *jpeg_buff;
    int jpeg_buff_size;
    jpeg_buff=0x80000;

    jpeg_buff_size = 308280;     //jpeg_buff_size = 480*640*1;
    FILE *jpegfp = fopen ("myimg_reconstr80000.bmp", "wb");
    fwrite (jpeg_buff, 1, jpeg_buff_size, jpegfp);
    fclose (jpegfp);

Please anyone knows how to create / write / save *.bmp image from that Raw Pixel Data located in Blackfin memory in C language?

Thanks in advance; any solutions, suggestions will be appreciated!

Below is the link with archive of the entire Visual Dsp project. (i'm using VisualDsp++ 5.0) https://docs.google.com/open?id=0B4IUN70RC09nMjRjNzlhNTctMTI3OS00ZmI4LWI4NzAtNWRkM2MyMDgyMjZm

*excuse me for my english writing errors


Solution

  • Before all the pixel data, add information for the bitmap header.

    http://en.wikipedia.org/wiki/BMP_file_format#Bitmap_file_header

    If you write this header data before your image data, it should be a valid bitmap file.