Drew
Drew

Reputation: 710

convert hex(png) file to rgb values

I converted a PNG image to hex and am wondering if it is possible to decompress the hex into this type of format for each pixel of the image:

Opacity(0-255)-Red(0-255)-Green(0-255)-Blue(0-255)

I'm using a site/program that has heavy restrictions on images you can upload(quality, size, amount, etc,) but I can create images pixel by pixel. I was hoping to decompress the hex that I converted from the original PNG file to the format above so that I can create a simple function to build it on the screen. Come to think of it, is there a way to pull the RGB and transparency from the hex PNG file without any need for reformatting?

Upvotes: 1

Views: 4193

Answers (1)

SachaDee
SachaDee

Reputation: 9545

It is very easy you have to cut your hexvalue, and applicate an HEX to DECIMAL CONVERSION.

Ex : FFAACC00

FF = R = 255
AA = G = 170
CC = B = 204

00 = Transparency Full (FF = Transparency OFF) 

If you need a program to do that you can use PNG2HEX.exe :

Download

(just drop your PNG File on it and it will create 2 files :

1- fileHex.txt with the value of each pixel in Hexa 2- FileRGB.txt with the value of each pixel in R G B

You can then modify values in these files and rebuild the png with the modification using HEX2PNG.exe

Upvotes: 3

Related Questions