473,569 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1801
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 imagecolorsfori ndex. 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 imagecolorstota l() 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***@glassgian t.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
8670
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 say the header won't. The below style will display the borders in print preview, but won't display the background color. Does anyone know if it's...
6
6130
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 my mappings between named colors, HEX values and the Long Integer values used in Access are not jibbing. Anyone have a nice list laying around? ...
1
2088
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 know the number of icons in the file ? Thanks in advance for your help.
0
352
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 Visual C++ 6 help I see: Return Values If the function succeeds, the return value is the RGB value that the function sets the pixel to. This value...
6
2229
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 COLLECTION OF ALL COLORS { htr = new HtmlTableRow();
2
1056
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.. Thanks, Smith
11
2244
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 the blue wavy line indicating an error. Help!
1
1869
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 = System.Drawing.SystemColors.Control; Then in my child form in the designer, I want to be able to enter "myColor" in the BackColor property.
12
2458
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 256 colors. Thanks, Steve
0
7697
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8120
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7968
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.