Displaying images from USB storage SK-S7G2

Hello,

I'm working on the SK-S7G2 board with e²Studio and GUIX to build my GUI application. 

I want to display 29 images on my screen, a touch on the LCD panel slide to another image, however the board only supports 9 images registered as pixelmaps in my GUIX application.

I saw the USB example that provides a way to modify a file in a USB storage. Is it possible to store all my images in a USB mass storage and to display them on my panel? 

Best regards,

Charlotte

  • Hello Charlotte,

    GUIX supports more than 9 images registered as pixelmaps, however you should make sure that all of the resources can fit in the flash memory on the device (4MB for S7G2). You can store your images on the USB mass storage device, but they cannot be used as GUIX resources. You can still display them on the screen but you won't be able to assign them to any widget as they won't be visible from GUIX Studio (GUIX Studio is unaware of what resources you put on the USB stick). Please look at the following example showing how to open JPEG files from the USB storage and display them on screen using GUIX: s7_sk_gx_ux_jpeg_1_1_0.zip

    Regards

  • In reply to Karol:

    Hello Karol,

    It is effectively possible, I didn't recognize the little issue concerning the name given to the images, some symbols are not supported in the generated files and induce errors.

    Thank you for the explanation and the example.

    Thank's for your help,

    Best regards

  • In reply to Cha:

    Hi Karol,

    I have been using this example in order to read a JPEG image from USB and then display it on the LCD, however I can only see a black screen when I display the pixelmap created from the JPEG. When the application starts, I have a window with a background pixelmap ocnfigured in GUIX which shows perfectly, but after receiving the event from the USB thread the handler executes the following code and the screen goes to black:

    p_pixelmap = (GX_PIXELMAP *) event_ptr->gx_event_payload.gx_event_ulongdata;

    gx_system_dirty_mark(widget);

    I tried copying a pixelmap from the GUIX resources file into the p_pixelmap and then it works fine so the problem seems not to be at the displaying side, it must be something related to the point where I am creating the pixelmap from the read jpeg image.

    Do I have to use a specific type of JPEG image? Do I have to use the jpeg decode framework at any point?

    I am using the PE-HMI1 board.

  • In reply to iparra:

    Hello,

    The JPEG image has to be compressed using baseline algorithm (not optimized nor progressive), otherwise the hardware JPEG decoder will not be able to process it.

    Regards

  • In reply to Karol:

    Hello again Karol,

    I have tried loading not optimized and not progressive JPEG images with 4:2:0 downsampling created with GIMP (I am not sure if this is the cirrect way) but still it does not work.

    We are using the PE-HMI1 board. We have two threads, one for the USB and another one for the GUI, and we are able to send the pixelmap to the GUI via an event, and display pixelmaps generated with GUIX (without RAW format) but when we do the same for our generated jpeg_info pixelmap, the screen goes black.

    I have realized that the flag of our jpeg pixelmap is set to RAW so I tried to reproduce the same pixelmap using GUIX but I receive the following error message: "This image is not compatible with the target hardware decoder."

    Is it possible that my target cannot decode a raw image? In that case what can I do to show JPEG images in my screen?

    In GUIX configuration I have 2D Drawing Engine disabled and Runtime Image Decoders set to:
    - JPEG: Hardware JPEG Decoder

    - PNG: Software PNG Decoder

    Thanks,

    Iparra.

  • In reply to iparra:

    Hello,

    Can you verify that your "gx" properties are configured to enable D/AVE2D and JPEG Decode engine? Additionally, I recommend disabling software PNG decoder as it requires further configuration in your application in order to get it running. Also, this does not work with SSP 1.2.0-b.1, as pointed out in release notes: "JPEG hardware rendering may cause system crash when rendering a raw JPEG data.".

    Regards

  • In reply to Karol:

    Hi,

    We have both engines enabled, and the SSP version we are using is 1.1.3.

    Any other idea? Why is it that the GUIX says that the raw images are not compatible with our target?

    Regards,

    Iparra

  • In reply to iparra:

    Hello,

    If your JPEG is encoded with YCbCr420 subsampling, please verify that both width and height of the image is divisible by 16 (minimum coded unit for 4:2:0 is 16x16 pixels). Also, in properties for sf_el_gx, make sure that the JPEG buffer size is sufficiently big to store decoded bitmap (even though GUIX should be able to use output streaming with much smaller buffer).

    Regards

  • In reply to Karol:

    Thanks Karol,

    now I am able to display JPEG images.

    However I still have a couple of issues:

    1- For some sizes of images the image is not displayed properly (for example a full screen image of 480x800 pixels and 38.416 bytes). I have used a JPEG buffer size of 524288 and memory sections for GUIX Canvas Buffer and JPEG Work Buffer in sdram. Any idea?

    2- Is it possible to use this imported image as a pixelmap created with GUIX using functions like gx_pixelmap_button_pixelmap_set? Is it possible to include them in the pixelmap_table dinamically or something like that?

  • In reply to iparra:

    Hello,

    Seems like you may have enabled additional screen layer by accident (verify in r_display properties that only background is set to "Used"). If that's not the case, try increasing JPEG buffer size to 768000 as that's the size of uncompressed 480x800x16bpp bitmap.

    Using imported images (i.e. ones that are added in GUIX Studio) is only possible through canvas drawing functions. To use your own external image with pixelmap button, you'll need to specify custom drawing function for that widget (which is exactly what I do for the window in the example provided).

    Regards

  • In reply to Karol:

    Thank you Karol,

    The image is perfectly shown now.

    Regarding the canvas drawing, I tried to display the image inside an icon, but the image is not centered inside the widget but in the 0,0 position of the x and y axis. Do I have to set manually the position of the image for each gx_canvas_pixelmap_draw() function call?

    Regards,

    iparra

  • In reply to iparra:

    Hello,

    Drawing functions in GUIX accept absolute co-ordinates only. This means that if your widget sits at 100,100, you should call gx_canvas_pixelmap_draw(100, 100, p_pixelmap); Moreover, you can use widget properties to get this position automatically: gx_canvas_pixelmap_draw(p_widget->gx_widget_size.gx_rectangle_left, p_widget->gx_widget_size.gx_rectangle_top, p_pixelmap);. In order to center your image, use gx_widget_size members and known screen dimensions to apply necessary offset when calling gx_canvas_pixelmap_draw.

    Regards

  • In reply to Karol:

    Ok, I think that will do it by now.

    Thank you so much!