473,385 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

GD choosing what colors to display

Hello

How can i use the GD Library to only show the White (or the hex value of
white) pixels of a image?

Imagine i have a 8 color picture in PNG format.

This is to use on a color puzzle that im trying to build...

1 - The user sees a completely BLACK image with the original size of
the picture

2 - the user selects GREEN (from a color palete)

3 - the image updates and shows all BLACK/GREEN pixels (using
something like "ShowImage.php?c=BG" or anything else)

4 - the user selects RED (from a color palete)

5 - the image updates and shows all BLACK/GREEN/RED pixels (using
something like "ShowImage.php?c=BGR" or anything else)

and so on...

Is this possible using the GD Library?

I can read the file from PNG and show it (using the gd library), i can even
change the pallete of the image based on another file's pallete, but i
wanted to dynamicaly change which colors to show on screen, based on user
input.

Any help on this appreciated, since im feeling a lit bit lost... Even the
funtion that has to be used to achive this will be enough for getting me
started.

Thanks,
RootShell
Jul 17 '05 #1
1 1793
RootShell wrote:

How can i use the GD Library to only show the White (or the hex value of
white) pixels of a image?

Imagine i have a 8 color picture in PNG format.

This is to use on a color puzzle that im trying to build...

1 - The user sees a completely BLACK image with the original size of
the picture

2 - the user selects GREEN (from a color palete)

3 - the image updates and shows all BLACK/GREEN pixels (using
something like "ShowImage.php?c=BG" or anything else)

4 - the user selects RED (from a color palete)

5 - the image updates and shows all BLACK/GREEN/RED pixels (using
something like "ShowImage.php?c=BGR" or anything else)


This isn't too difficult. You'll probably want to use imgcolorstotal,
imagecolorat, imagecolorset and imagecolorsforindex. Loop through all the
colors in the palette and set any color that's not one you want to display to a
default color. Note: you imagecolorstotal() doesn't work for true color images.

You may even be able to use some of those functions to determine what colors are
in the image and offer them in a dynamically-generated server-side image map.
That way you don't have to worry about your users clicking colors that aren't in
the image. Just keep track of what colors are selected in a session variable.
In other words, allocate a 25x25px block to each color. If the user clicks
between 0,0 and 24,24 (corresponding to index color #1), then show that color.
This may or may not apply to your situation. I don't know what the images are
or how you get them.

Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Scott | last post by:
There is a setting in IE for "Print background colors and images." I've noticed that without checking this option, a web page will print CSS lines between table rows, but a background color of...
6
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but...
1
by: Krazitchek | last post by:
Hi, how to navigate between icons stored in shell32.dll (or other .dll), choose one of them with the index, and one particular format of the choosen icon (16 colors, 256 colors, XP) ? How to...
0
by: mark | last post by:
Somebody can explain me why if I put a color with SetPixel the color showed is of another value? For example: I've to draw a grayscale image. The color RGB(90,90,90) become RGB(40,45,60). In the...
6
by: Mark | last post by:
Is there a programatic way to iterate through all the named colors? Something like: HtmlTable ht = new HtmlTable(); HtmlTableRow htr; HtmlTableCell htc; foreach (Color c in ) //I CAN'T FIND...
2
by: Smith | last post by:
I have developed a web based application targeting various browsers (different versions). When I select the color... do I have to make any considerations? Anything like true font etc.. ...
11
by: Paul Smith | last post by:
I have a button on my web page the backcolor of which I want to change: btnSample.backcolor = ???????? I want the color to be Gainsboro However I enter Gainsboro or color.Gainsboro I have...
1
by: Demi | last post by:
I want to be able to define standard colors in a base form, then have child forms use those values instead of standard colors. Ex in my base form I want to do this: Color myColor =...
12
by: Zamdrist | last post by:
Been awhile since I've done any significant html work. Was wondering if I need to worry at all about colors and using html safe colors? I can't imagine too many people browsing the web anymore at...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.