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

Home Posts Topics Members FAQ

how do i replace pixels colors with my own colors ?

69 New Member
Hi I am new to the GD library and am stuck on something and wondered if you could help me.

I am using PHP and GD.

I have an array with 40 predefined hexadecimal colors in it.

I have an image that is 6 x 6 pixles, and I would like to loop through the pixles, swapping the colours in the image for my predefined colors.

if say pixle 1 was already in my predefined colors i would like to leave it there and move to pixle no.2 else i would like to change that pixle in the image for the closest match that i have in my predefined colors.

i would like to loop through the whole image untill the last pixle is complete.

i have looked at imagecolorexact () , imagecolorresol ve() imagecolorclost est(), and even a mix of all, but i cant get my head around the best way of doing it. please help :)
May 28 '12 #1
0 1292

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2351
by: baruch | last post by:
Hello! I'm using PHP Version 4.3.3RC5-dev with GD Version bundled (2.0.15 compatible) to generated some graphics based on mysql data and to my surprise when I use the GD function imageline($im, $x1, $y1, $x2, $y2, $cl); (with $cl being the collorallocated via function) the line is draw dirtying the contiguous pixels of the image ($im),...
1
1801
by: RootShell | last post by:
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
7
2891
by: Laszlo Zsolt Nagy | last post by:
Hello, How can I determine the number of colors used in an image? I tried to search on Google but I could figure out. I read the PIL handbook but I do not see how to do it. Can anyone help? -- Best regards, Laszlo
20
3034
by: Tyler Carver | last post by:
I would like to do something that seems so basic with two div's but I don't think it can be done. Tables can do it in a snap. I was convinced that css was the way to go for layout but without being able to do even the easiest things, I don't see how. Here is the table way to do the layout (I want this to work in compliance mode in all...
2
2415
by: jrhoads23 | last post by:
If you look at a standard Button in a .NET Windows Forms app, you will notice its default BackColor is "Control" and it has a 3D raised border which is 2 pixels wide. The outer edge on the left and top is "ControlLightLight" color and the inner edge on the left and top is "ControlLight". The outer edge on the right and bottom is...
3
6415
by: Typpo | last post by:
Hi all, I'm trying to compare a color returned by a Bitmap's GetPixel method to a normal static color of the Color class. My problem: after setting a pixel to a certain color, the color returned by GetPixel isn't considered the same color anymore. Example code: bmp.SetPixel(0, 0, Color.Blue); Color cc = bmp.GetPixel(0, 0);
4
23846
by: Ma Xiaoguang | last post by:
Dear ladies and gentlemen: How to access all the pixels of a bitmap with C#? I am working with Delphi before. In Delphi, you can use TBitmap.Scanline property to access all the pixels of a bitmap object. How to do this with C#? Any hints? Thank you very much. Best regards. Xiaoguang
4
3938
by: Jmc | last post by:
Hi Need some advice on how to get all colors in an image. I wish to have an input file, in my case it will be a scanned piece of fabric. I would like to first of all gen an array with all the colors represented in the image. and an percentage of how much the color exists. Lets assume that the color of the fabric is blue, it will probably...
9
4156
by: Richard | last post by:
Please hlep with a very frustrating problem. I need to be able to have a reference to my "btcopyrights" CSS class override the link colors first specified earlier in the CSS. I inherited a large site with a CSS containing as its first lines: A:link { COLOR: #006633; BACKGROUND-COLOR: transparent;
2
1752
by: smullen.uclick | last post by:
I'm not entirely sure how this group works: if there is a page I'm supposed to follow up on or if I should expect an email in reply. Anyway, here's my question. I'm very new to Python and PIL, I know how to do this stuff in perl and ImageMagick, but I'm having issues with Python and PIL. I need to scale a TIFF image from 1925x588 px to a...
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
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...
1
7672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
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.