LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 03-13-2008, 02:55 PM   #1
rubadub
Member
 
Registered: Jun 2004
Posts: 233

Rep: Reputation: 33
Accessing palette in GD using C


Hi, I have some PHP code which I can use but I can't seem to find the equivalent code in C. Here's the code from the PHP manual:
Code:
// get a color
$start_x = 40;
$start_y = 50;
$color_index = imagecolorat($im, $start_x, $start_y);

// make it human readable
$color_tran = imagecolorsforindex($im, $color_index);
Basically i'm after any way to read out the palette (index + colour), cross reference colours, or just return the palette index from a position.

I'm looking through gd.h but seem unable to find the appropriate function(s), any suggestions appreciated!
 
Old 03-13-2008, 03:08 PM   #2
rubadub
Member
 
Registered: Jun 2004
Posts: 233

Original Poster
Rep: Reputation: 33
Well, it's not a function but by directly accessing the structure I can do what I want...
Code:
c = img->pixels[3][3];
printf("c: %d -> colour: %d, %d, %d \n", c, img->red[c], img->green[c], img->blue[c]);
 
  


Reply

Tags
gd


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VIDIOSPICT invalid palette meinnit Linux - Hardware 0 03-08-2007 05:15 PM
wxDC + get current palette bianchi Programming 0 12-04-2005 11:56 PM
aterm color palette efoo Linux - Software 1 10-11-2005 08:00 PM
What is the Palette of Mandrakes Kernel? john_walsh54 Mandriva 1 09-12-2003 02:26 PM
Wrong palette used by TV-out Otto.W. Linux - Hardware 0 06-15-2003 10:47 AM


All times are GMT -5. The time now is 02:49 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration