Trouble writing PNGs with 16 bits per channel using libpng - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Trouble writing PNGs with 16 bits per channel using libpng (/thread-3946.html)
Trouble writing PNGs with 16 bits per channel using libpng - flash - Aug 27, 2006 06:17 AM
I've been working on a more sophisticated height map implementation (hopefully on the way to proper bump mapping) and I've been using PNGs with the red channel as the height data and the green, blue and alpha channels as the x,y and z components of the normals for each vertex.
I wrote a program to read in an image, calculate the normals and write out such a PNG. I got it all working using 8bit precision and it looks ok, but not as good as calculating the normals in the rendering program at higher precision. So I converted my program to use a 16bit colour depth and it works up til writing out the PNG at which point gdb says:
mi_cmd_stack_list_frames: Not enough frames in stack.
This is in png_malloc when in png_create_write_struct2 it seems.
I'm using a test image of 16x16 (the 8bit program works with 512x512 ) so I find it hard to believe there really isn't enough space on the stack, butI'd freely admit I don't really understand what's going on.
My write function is here:
Any help most appreciated - sorry for the rather long post.
Trouble writing PNGs with 16 bits per channel using libpng - Frogblast - Aug 27, 2006 01:30 PM
Post the code that calls this function. Specifically, how do you allocate the buffer pointed to by image_data?
Trouble writing PNGs with 16 bits per channel using libpng - flash - Aug 28, 2006 11:01 AM
I actually got it working - I was overrunning an array way back in the code. Now it seems I'm not getting all 16 bits when I read a PNG. I'll just have to keep hacking I suppose...