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?

StackOverflow https://stackoverflow.com/questions/8774279

Question

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

To mention a "resume":

  • I build the project;

  • Load an black&white image (*.bmp) from disk to Blackfin memory at 0x8000 with Image Viewer;

  • Run project;

  • Push a button (from SW 10 to 13) from the BlackFin board (BF537) and select a level of compression;

  • After calculating the quantization table and DCT->Quantization->Dequantization->Inverse DCT.. results a reconstructed image at some adress point in BF memory (0x80000);

  • With Image Viewer (from VisualDsp) i load that reconstructed grayscale image from BF memory and it's everything ok, and differences are visible;

!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: - to take ( create / write ) [in C language] that reconstructed image from Blackfin memory into disk (writing a code, or something like that; NOT with Image Viewer feature - Save image as... ).

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

Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top