/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Issues with DRAW_SetImage

Username:     
Password:     
             

Forum

# 1   2009-01-26 11:37:43 Issues with DRAW_SetImage

sjoerd
Member
From: Stad aan het Haringvliet
Registered: 2008-09-04
Posts: 65

Issues with DRAW_SetImage

I'm having trouble using DRAW_SetImage with the expected width and height of an image.

I converted a JPG into the 65k colorspace used by the LCD controller with the following code .NET C#:


           Bitmap b = new Bitmap("D:\\temp\\image.jpg");
           
            Int16 pixel;

            using (BinaryWriter bw = new BinaryWriter(File.Open("D:\\temp\\image.prm", FileMode.Create)))
            {

                for (int i = 0; i < b.Height; i++)
                {
                    for (int j = 0; j < b.Width; j++)
                    {
                        Color c = b.GetPixel(j, i);
                        pixel = (short)(((c.G & 0x07) << 13) + ((c.G) >> 5) + (((c.B) >> 3) << 8) + (((c.R) >> 3) << 3));
                        bw.Write(pixel);
                    }
                }
            }

So the bitmap is written to the output file line by line. File is copied to SD card


Then from Primer2 read from disk and displayed with:

          DRAW_SetImage(ImageBuffer,0,0,ImageHeight,ImageWidth);

Problem is that it is displayed 90 degrees rotated counterclockwise and
DRAW_SetImage expects first Width and then Height.


Any idea what can be wrong here?

Offline

 

# 2   2009-01-26 12:57:59 Issues with DRAW_SetImage

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: Issues with DRAW_SetImage

Yes, I don't know the reason but I remeber now that I had to rotate the new images by 90 deg (home page + icons for the sound) to get them in the right orientation. 
It is due to the LCD chip (ST7732 for Primer2) that fills the memory in that way. The DRAW_SetImage function, only sends the data to the chip...
If we want to manage image in memory, we would have either to implement a function that 'rotate in memory' the images, or to write another function that would send the data in a better way (line by line).

Offline

 

# 3   2009-01-27 07:47:55 Issues with DRAW_SetImage

fastmapper
New member
Registered: 2008-11-15
Posts: 3

Re: Issues with DRAW_SetImage

The LCD controllers found in the Primers are very flexible and can handle images in a large number of arrangements.  The DRAW_SetImage function (together with the screen orientation logic) was apparently designed to operate using a relatively unconventional approach.
It would not be too difficult to use the LCD driver functions (in lcd.c) to implement an image drawing capability that is suited to your needs and to your style.

Offline

 

# 4   2009-01-27 10:48:42 Issues with DRAW_SetImage

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: Issues with DRAW_SetImage

fastmapper is right. We took a convention to define the order for filling a rectangle that probably not the most conventional.... As long as we were in a our system, it was not an issue. Now that we want to open standard JPEG, it could be more difficult. We would have probable to duplicate SetImage to handle the most conventional orientation...

Offline

 

Board footer