Displaying GIF and JPEG files

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Displaying GIF and JPEG files

6,254 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jeffbelz on Fri Apr 05 08:18:30 MST 2013

I have been succesful in displaying a Bitmap via GUI_BMP_DrawEx() function from emWin.  However, now I want to display a GIF and a JPEG. 


When I use GUI_JPEG_DrawEx() or GUI_GIF_DrawEx(), my image does not load.  What could be wrong?  Do I have to do anything special for these formats?

Labels (1)
0 Kudos
Reply
18 Replies

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Mon Jul 22 02:44:18 MST 2013
Clearly libpng is somehow reading corrupted data.

Considering the same code runs fine on another board (the EA1788 board), I would definitely first make sure the external memory bus is working correctly (in all supported modes).
To rule out any problems related to your image files, SD card etc, I would also try to run in on the EA1788 board yourself. I expect it runs fine then also, else you're having problems with the image files/SD card.

If it runs fine on the EA board at your side too (I'd expect so), then there must be some H/W difference between the EA1788 board and your custom board. Perhaps it's an H/W error, or only something which needs other settings in software.
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by e135193 on Sat Jul 20 01:46:57 MST 2013
Hello Wouter

     I ran the code many time and I took some screen captures which shows different behavior. I took these capture with "emWin_520_IAR650_M3_LE_d5.a" debug library.

     I hope these captures helps you to understand more clearly.

Regards

e135193
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Fri Jul 19 01:57:53 MST 2013
That's too bad!

I have no idea what's going on. I understood you had a EA1788 board, can you get a hold of that board again to see if it works on that board?
I've ran emWin with PNGs and JPEG on many board without any trouble, so I doubt the error is caused by emWin or PNG/JPEG files.
You could replace the emWin library by any older version that we have on LPCware.com to see if that makes a difference. For a quick check it should be sufficient to simply add the .a file to the folder, remove the current .a file from the project and add the other .a file.

Further:
Register R1 should contain a pointer to an error message when it hangs in png_cexcept_error(). Can you give me the address of that pointer,  and the ASCII data that you find at that pointer? It should provide a glue what's going on...

You can also try to link against the debug version of the emWin library, emWin_520_IAR650_M3_LE_d5.a. I'd expect to hang it self in GUI_Error(), where R0 should point to an error message.
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by e135193 on Thu Jul 18 08:43:55 MST 2013
Hello Wouter

     I tried the last pre-compiled files on my custom board but the result is the same. It freezes on the same code line "png_cexcept_error:"

     I even change the clock rates like below.    

     SystemCoreClock = 60MHz
     PeripheralClock = 30MHz
     EMCClock        = 30MHz

     As far as I understand this problem is not related to the compiler anymore. What could be done in this point ?

Regards

e135193
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Wed Jul 17 23:36:00 MST 2013
I retried the EA project with 230x120 images, which also works.

I assumed your previous attached project was already the one suitable for your board, but now I've attached the compiled binary of your last attachment too. On the EA board nothing is being displayed because of board differences, but breakpoints after "_DrawJPG_File("\\01.jpg");" and "_DrawPNG_File("\\01.png");" were hit, so at least it doesn't hang in these functions on the EA board.

There's no real logical reason why PNG and JPG would fail while BMP shows no problems. The only thing I can think of is a problem with the external memory. But I'm afraid there ain't much I can do without having access to your board to do actual testing on.
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by e135193 on Wed Jul 17 09:46:27 MST 2013
Hello Wouter

    Image sizes I used was 230x120. I suppose there is no display fit issue that I'm having. As you can see from the screen captures which I sent earlier, when code is in PNG branch, it crashes somehow.

    As I told in my last message, I don't have EA board for testing purposes. Therefore I can not test the pre-compiled code on my custom board. If you can compile the code I newly attached, I can then try it on my custom board. Then we can conclude that it is a HW specific problem.

    I tired some widgets like graph. They also worked well.

    What could be the specific problem related to PNG and JPG file ? Why the same HW configuration can draw BMP files without any problem ?

Regards

e135193

0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Wed Jul 17 05:16:42 MST 2013
Hi e135193,

I've downloaded your code and created an SD card with three images (bmp, png, jpg). On the EA baseboard with 7" display it runs fine and the three images are alternately being displayed.

I noticed the BMP was displayed near the top left of the screen, and the PNG and JPG more to the bottom right. I don't know your display size and image size (I used 128*128 for all three images), but perhaps they simply don't fit in your display's visible area?

Besides the possibly not-correctly working external memory interface, I wouldn't know what is causing failure of PNG/JPG files.
To rule-out compiler issues, I've uploaded the compiled binary of your project. You can save the .out file and use it in the previous "pre-compiled project" I've send you before. Simply remove the old .out file from the project, and add this one instead.

If you keep having problems, I'd expect board issues. In that case I don't think it's limited to PNG/JPEG files not working, you could try out a few of the examples provided on http://www.segger.com/emwin-samples.html and see if other widgets cause problems too.

Regards,
Wouter
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by e135193 on Wed Jul 17 01:53:45 MST 2013
Hello Wouter

  I can not share the layout since I did not route the board and I don't have the layout files.

  Could you try the code I share on EA board? The code is compatible with EA board. Use IAR as the compiler and you need files 01.bmp, 01.jpg and 01.png on SD Card. I added File System files to the project. I suppose that you can easily compile and download it into the target.

  I appreciate if you share the outcome you see.

regards

e135193
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Tue Jul 16 23:57:51 MST 2013
If it's a custom board, the external memory could be the cause. The layout and configuration of the EMC is critical. In some cases it may appear to work correctly, but would fail in e.g. burst mode. This could corrupt the JPG/PNG data/buffers, leading to decompression failures.

Did you use the exact same external RAM as on the EA board? if not, are you sure you've properly ported the SDRAM init code?
Can you share the layout of your design, or at least the part showing the SDRAM and LPC?
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by e135193 on Tue Jul 16 11:47:08 MST 2013
Hello Wouter

    I can not tried the pre-compiled files on EA board because I do not have that board any more. I tried to use it on a custom board but the outcome is a failiure. I have to say that this custom board runs emWin APIs well and even BMP draw APIs but not JPEG and PNG APIs.

    Do you want me to share the code I use ?


Regards

e135193
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Tue Jul 16 03:29:26 MST 2013
That's very strange! I assume that's with the project I had attached to my previous post?
I've got the same project running just fine on my board...

Looking at the call stack, the libpng seems to encounter errors in the png data.
Did you perform a verify after downloading it to your target?

I'd suspect a H/W problem or either a compiler issue. Which version of IAR are you using? And which screen have you connected to the EA base board? QVGA, 4.3", 7"?
Can you open attached project and download it to your board? The project has my pre-compiled binary of the previous project, so this should indicate whether it's a H/W problem or an issue with your toolchain.
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by e135193 on Mon Jul 15 13:44:16 MST 2013
Hello Wouter

   I guess that there is a problem. Code freezed in a line which you can see from the picture I attached.
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Mon Jul 15 06:47:57 MST 2013
Hi e135193,

The emWin 5.20 BSP should work fine with PNG and JPEG images. Please see attached archive, which is basically the emWin 5.20 EA1788 BSP with two modifications:
- File PNG_Demo.c is added and set as active application in the Keil, IAR and LPCXpresso projects.
- The LPCXpresso linker file is changed to use the redlib nohost C library instead of the redlib none C library (explanations) to solve linker issues.

The project works fine here on the EA1788 developer's kit. Please let me know if you have any more issues.

Regards,
Wouter
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by e135193 on Mon Jul 15 05:50:01 MST 2013
Hello Wouter

Here are the answers you need.

-Device;   LPC1788
-Board;    Embedded Artist
-BSP;      Downloaded form lpcware.com
-emWin;    5.20
-Error;    No compilation error
-SW Error; My code don't crashes somehow and don't end up hardfault handler
-RAM;      I'm usign 12MB ram, haven't try to increase

I must say that the code works well for Bitmap files but not for PNG and JPG files

Regards
e135193
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Mon Jul 15 03:24:29 MST 2013
Hi e135193,

Can you give some more info? E.g.:
- Which device are you using?
- Are you using a commercial board or a custom board?
- Do you make use of one of our BSPs?
- Which version of emWin are you using?
- No compilation errors?
- The SW hangs, ends up in hardfault handler, or just continues when drawing PNG/JPEG without actually displaying it?
- Did you try increasing the RAM available to emWin? (i.e. GUI_NUMBYTES if you're using our BSP)?

Regards,
Wouter
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by e135193 on Sun Jul 14 05:38:03 MST 2013
Hi Wouter

     I have the same problem. I can not draw JPEG and PNG files via emWin. I successfully draw BMP files. Could you tell me where I make mistake ? I share the code I have. I'm using emFile as the fileSysem, as well. I need to say once again that Bitmap part of my code works well.



Regards

e135193
0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Mon Apr 08 00:35:00 MST 2013

Hi,


You may want to have a look at the <a href="http://www.segger.com/emwin-samples.html"><strong>Drawing scaled JPEGs</strong></a> sample. It's description:


<em>Shows how to draw scaled *.JPEG files by displaying all JPEG's</em>
<em> from a user definable directory without loading them completely</em>
<em> into memory.</em>


Regards,


Wouter

0 Kudos
Reply

5,275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jeffbelz on Fri Apr 05 12:41:30 MST 2013

I got a GIF to load, but I had to change "#define GUI_NUMBYTES " to 30000.   This kills my RAM. 


I'm loading the image from an external FLash.  How can I use the flash as temp data, or use another external RAM.  

0 Kudos
Reply