Looking for PNG decoder (RLP Raptor)

Does anybody knows a png decoder implemented in pure C, to port it to RLP?

I want to download and show map tiles that is compressed png images.

I’ve tried to use a LodePNG
It compiles succesfully for G400 via emBlocks but does not work for some reason (board reboots). May be because there is a references used or another thing that is unsupported by RLP.

I don’t know how it is possible to debug or test a RLP code thus it is seems very hard to me to get it work.

Another idea is to port Skewworks PNG Support Library to native code (because at least I’m sure it works correct with my type of png).

But may be this work is already done by someone? :slight_smile:

Make sure you only compile C files, no CPP. Do not include stdlib unless you sure if what you are doing, like in not using maloc.

I just looked at the code. Did you change maloc to use the provided rlp extension?

This is in the code…

/The malloc, realloc and free functions defined here with “lodepng_” in front
of the name, so that you can easily change them to others related to your
platform if needed. Everything else in the code calls these. Pass
-DLODEPNG_NO_COMPILE_ALLOCATORS to the compiler, or comment out
#define LODEPNG_COMPILE_ALLOCATORS in the header, to disable the ones here and
define them in your own project’s source files without needing to change
lodepng source code. Don’t forget to remove “static” if you copypaste them
from here.

@ Gus - no, I didn’t changed malloc because I remember John was told in another thread that malloc is implemented in RLP.

Can you also clarify about references? Is its are supported?


Yes maloc is implemented in rlp extensions, not stdlib maloc. Take a look at the rlp extensions.

@ Sergey Bokhantsev - if you get it working I’d love a copy.

So I was not able to port lodePng library because of lack of experience with C.

Instead of that I almost finished porting Skewworks c# library back to C :slight_smile:
I think it will be work soon. Currently it already does decoding in C test project.

I need to add invoking method that will be an entry point for Raptor.
This method will accept two arrays: png binary data and target bitmap array to draw decoded image to.

1 Like

Guys, I need help

That’s what I’ve done:

  1. Ported c# code to a new cpp project in VS (using only C features).
  2. Debugged this port to make sure it decodes incoming data properly.
  3. Copy-pasted code into em::Blocks project that is configurred for G400 RLP (Simon from Vilnus template)
  4. Fixed some minor compiler-related issues like you must declare variable outside ‘for’ loop and so on.
  5. Then em::Blocks project began to builds successfully and without any warnings.
  6. I copy-pasted this fixed code back to VS project to double-check that decoding still worked fine.

So everything looks fine but calling this RLP procedure on Raptor crashes the application. (I use the same incoming data both for Raptor and VS).

Is it possible to somehow setup a desktop debugger in em::Blocks or VS to debug this code in more Atmel-like environment or something like that.

I mean there must be a way to find why the same C code works correctly compiled for desktop and fails on Raptor.

Any advices are welcome

Have you had a simple minimal RLP function running yet?

Yes, I did a simple function to flip a bitmap that works fine.
Also RLP->malloc and free functions are new for me thus I’ve created a test function like allocate memory, write some array to it, read this array back, free memory. This is also works as expected.

1 Like

I don’t know of a way to debug RLP on the device. If you can share the code I’m sure someone will see the issue.

I should try to compile and debug this code within the Atmel avr studio IDE. As it seems this ide can compile C sources with respect to target MCU architecture, thus I believe, it can help me to find a root cause of a bug.

If there will be no results then I will share my code for community to rewiew :slight_smile:

1 Like

Wow, finally it works.

The crash reason was that you cannot just define such big array as
int array[1024 * 30];
(because of stack limitation ?)

After this hardcoded array was replaced with a dynamic allocation this crash was gone.
There was also few more minor bugs, so after two hours of debugging it finally has drawed a valid image to my screen.

I had not meassured the decode time, but I think it is about 0.2 - 0.5 sec for 256x256 compressed PNG image.


@ Sergey Bokhantsev - Good job!

@ Sergey Bokhantsev - excellent. Using rlp a stand alone?

@ Sergey Bokhantsev - nice. Well done.

Well done! I’m pretty sure my managed code version takes somewhere around a full minute for an image that size

I’ve posted the code on codeshare