C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 01-11-2010, 10:34 AM   #1
Registered User
 
Join Date: Jan 2010
Posts: 3
getting pixel data from image using libpng

I am trying for create a program that performs 2-dimensional fast fourier transforms on each pixel of data in an image. I am going to transform each channel seperately, then map the coefficients to colours and recombine them into an image.

But I cannot seem to figure out how to read/interpret the pixel data using libpng. Can someone help me find out how I would read a png image and read each pixel's data into an array?
mamacken is offline   Reply With Quote
Old 01-11-2010, 10:51 AM   #2
Registered User
 
Join Date: Sep 2006
Posts: 3,148
We don't work quite that way.

YOU show US what you've done to try to solve the problem, and where you're stuck - with code, preferably.

When we see code that you're working with, we can be specific. Without it, we can't be specific.

Is your file a PNG file? Did you read up on it's format? Did you look at it's contents with a Hex Editor? How did you open the file? What kind of variables did you use?

See what I mean?
Adak is offline   Reply With Quote
Old 01-11-2010, 11:18 AM   #3
Registered User
 
Join Date: Jan 2010
Posts: 3
I don't really have code to show you that would be of any help. But I can be more specific with the nature of my problem.

My program reads in a PNG file and I can fetch it's width and height from the info structure. I also know how to read each row into an array of type png_bytep. I have no idea how I am supposed to access the individual color components of each pixel from the byte array though. I apologize for my vague description initially, I am just new to this particular library, and it's common usage is apparently quite different than what I am attemping to use it for.
mamacken is offline   Reply With Quote
Old 01-11-2010, 11:27 AM   #4
Senior software engineer
 
brewbuck's Avatar
 
Join Date: Mar 2007
Location: Portland, OR
Posts: 5,768
If the pixels are 24-bit RGB, then the data is composed of interleaved and repeating R, G, and B samples. R comes first, then G, then B.

Code:
unsigned char *red = (unsigned char *)ptrToRow[ Y ] + 3 * X;
unsigned char *green = (unsigned char *)ptrToRow[ Y ] + 3 * X + 1;
unsigned char *blue = (unsigned char *)ptrToRow[ Y ] + 3 * X + 2;
__________________
"Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot
brewbuck is offline   Reply With Quote
Old 01-11-2010, 11:37 AM   #5
Registered User
 
Join Date: Jan 2010
Posts: 3
Thank you very much.
mamacken is offline   Reply With Quote
Old 01-11-2010, 11:59 AM   #6
Registered User
 
rogster001's Avatar
 
Join Date: Aug 2006
Location: Liverpool UK
Posts: 452
this is a good article, though it is SDL >

Lazy Foo' Productions
rogster001 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
xor linked list adramalech C Programming 23 10-14-2008 10:13 AM
Abnormal Program Termination when executed from C:\Program Files\... m37h0d Windows Programming 48 09-26-2008 03:45 AM
Image rotation - doesn't always work ulillillia C Programming 12 05-03-2007 12:46 PM
[question]Analyzing data in a two-dimensional array burbose C Programming 2 06-13-2005 07:31 AM
Program Crashing Pressure C Programming 3 04-18-2005 10:28 PM


All times are GMT -6. The time now is 12:46 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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