Working with png files

This is a discussion on Working with png files within the C Programming forums, part of the General Programming Boards category; I am trying to make a program which can open a PNG file and allow me to access individual pixels ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    266

    Working with png files

    I am trying to make a program which can open a PNG file and allow me to access individual pixels identify their colors in some fashion so that I can determine where locations of interest might be in the image.

    I have found libpng and have managed to figure out how to open a file and pull out all chunks of data into an array but I am here to ask if anyone knows of a better way to handle this (if anyone knows a better library suited for the job), I am beginning to think that libpng is far too low level and won't help me beyond giving me the raw data from the file.

    anyone have any suggestions ?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You want to access individual pixels, but think that the raw data is too low level? Really?

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    266
    what libpng gives me is completely raw data, it isn't determined if the chunk of bytes is even color information...

    I understand that there has to be some sort of system in place to handle things such as transparency information, but there are many types of data in a png file... if only there were a way to just give me an array of pixels with each having an RGBA

    I guess if theres no other library to look into before continuing to read up on png chunk format, i will continue..
    Last edited by rodrigorules; 05-11-2010 at 08:01 PM.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,551
    Is there an issue with storing the entire decoded image in memory at once?
    libpng 1.2.5 manual
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Oh read this section too:

    libpng 1.2.5 manual #3.6

    libpng does not just give you raw data, but it is low level.

    I understand that there has to be some sort of system in place to handle things such as transparency information
    Couldn't tell you for sure, but maybe if you did some research into the png format you would know, and this might help you interpret the libpng documentation.
    Last edited by MK27; 05-12-2010 at 08:48 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    Registered User
    Join Date
    Aug 2005
    Posts
    266
    It turns out that it does give me color data, I was just interpreting it incorrectly .. was simple to figure out when I made my own 2 pixel by 2 pixel image.

    thanks all.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Working with multiple source files
    By abh!shek in forum C Programming
    Replies: 17
    Last Post: 06-03-2008, 11:23 AM
  2. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  3. Working with DLL files...
    By Devil Panther in forum Windows Programming
    Replies: 8
    Last Post: 11-14-2004, 11:42 PM
  4. working with resource files
    By the Wookie in forum Windows Programming
    Replies: 4
    Last Post: 02-01-2003, 09:26 AM
  5. reinserting htm files into chm help files
    By verb in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2002, 08:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21