This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

bmpToRaster issues

Hey, I've been trying to use the bmpToRaster tool included with StarterWare to convert an image and display it on an LCD, but it doesn't seem to be working properly. 

I built the tool on a system running Ubuntu, and I tried converting the image below using it, but I'm not really getting any meaningful output

The exact command I'm running is ./a.out 640 480 screentest.bmp image.h 24 RGB, and this is the file that it spits out:

4087.image.h

When I tried to load this file with my project, less than a tenth of the screen I'm using (vertically) gets filled with garbage and the rest is blank. 

My next thought was to compare my new image.h file with the image.h file included with the StarterWare project. The StarterWare file is around 40,000 lines, most of which contain nothing but 0x00ffffff entries in an array, which I assume represents white. When I look at the file I get from the bmpToRaster tool, the file is only around 2,800 lines (with the same formatting) and the array values are more or less random, which doesn't match up with the image I'm converting. As an aside, the ratio of lines of code between the StarterWare image.h and my own image.h matches almost exactly which the ratio between garbage on the LCD screen and the total area on the screen. 

My only guess at this point is that there is some issue with the bitmap I'm passing in for my argument, or with how the bmpToRaster program is dealing with it. I started looking at the source code and it was a bit over my head, but it looks as though there is functionality to handle different bitmap types (bit depths). The image I'm using is a 24-bit bitmap, so I was thinking that the program might be handling it differently and causing it to be squished. I really don't know much about bitmaps in general so this is more of a guess than anything. The program does understand the size of my bitmap, since I can only pass in "640 480" as parameters without getting an error. 

  • I just did another test by taking the same image and saving it as a monochrome bitmap (1 bit per pixel) and this shrunk the output file even further, the the point where the output is only 400 lines.

    From what I understand, bmpToRaster should be able to take various bitmaps, regardless of bit depth, and convert them to a consistent header format as long as the pixel size of the image is specified. Looking at the proper array from the StarterWare project, the number of elements in the array is pretty much identical to the number of pixels in a 640x480 screen. So I'm assuming that bmpToRaster is supposed to take a bitmap, and produce a header file which has every pixel explicitly expressed in this array format. So if you pass in a 24-bit bitmap, the output file would only be a few times larger since it doesn't contain much more information than the bitmap itself. But if you pass in a 1-bit bitmap, bmpToRaster should produce tons of redundant data just so the output matches the same format. In the case of my program though, the format of the output seems to depend on what type of bitmap is being passed in, which goes against the point of the program from my understanding.

  • Hi Matthew,

    By default, the "bmpToRaster" will generate the header file in compressed format. In the generated file, the three Least Significant Bytes will indicate the pixel value. The Most Significant Byte of a word will indicate the number of times the pixel repeats. If the number is <256 then, the Most Significant Byte will contain the count. If the number is >256, the number will be stored in the next WORD.

    Eg: If pixel value AABBCC is repeated 8 times, then PPQQRR is repeated for 10000 times,
    The generated file would contain the following representation for pixel values.
    0x08AABBCC, 0xPQQRR, 0x2710

    From your explanation it seems, the generated file is compressed one, because of this you are observing the size difference between your header file and the file present in the starterware. Starterware example will expect the header file to be in uncompressed format, that is why the image is not displayed properly.

    To generate the uncompressed image, please perform the below steps.

    1. Comment the line "#define COMPRESS"  which is present in the header file "BitmapReader.h"

    2. Then build the bmpToRaster application again using make command

    $make

    3. Then run your extract command.

    Please try to generate the uncompressed image and test.

    Regards,

    M.Jyothi Kiran

     

  • Sorry, but that does not fit to the result file I get. If I convert a file 800x480 pixel and count the 'x' as marker for an value within the result I get 384000. I used a almost white image to test it. And I enabled the #define COMPRESS in the header.


    But possible I use an outdated version. The copyright notice is from 2010.


    Regards,