Is there a way to get rgb colors from an image?

I want to basically get the pixel colors off of images. Is there a way to do this?

4 Likes

Nope - Roblox has no features for this (although there are some custom rendering things going on which I think can do textures? probably involves lots of weird math to manually get the color tho).

You could make create a separate, white image for the parts that change color and reference the ImageColor3 when you set its color.

2 Likes

I’d love to know those custom rendering things :slightly_smiling_face:, if anyone could provide them. I believe @Oseday integrated a way to render images.

3 Likes

Your best bet is to have a web server do the pixel scanning for you. The custom render things EmeraldSlash mentioned just raycast to find color and add shadows, AA, supersampling, and a few more things on the top. You’re gonna need an external service to scan images.

4 Likes

You can use Paint NET. You can use the syringe tool to pick up a color you want from the image and then check the color wheel and palette; if you expand it, it’ll give you RGB and HSV values.

Example:

3 Likes

ah but I want this to be done in studio through code.

1 Like

Oh, then that can’t be done iirc.

2 Likes

You should make a feature request for this. It’d be great if we could specify x and y coordinates into some sort of built in function and get the color at that point.

It’d be even better if this also included some way to get the color that the mouse is hovering over - that way we could get the color of a point on a decal that is wrapped around a sphere or something.

(I’d love this for a space game I’m working on. I’m using textures for the planets and I’d love to be able to just detect if the player is hovering over something blue (ocean) in order to limit building placement to be on land only.)

It’d also make creating color wheels and such for customization options so much easier.

I’d support if you did!

4 Likes

A simple GetPixel(x,y) function for decals would also be useful for generating terrain from height and material map decals. Currently you need to either use HTTPService, or an external program (e.g. python script) to write out your bitmap as a lua array you can paste into a script. It would definitely be a time saver to be able to sample pixels off of an image in /content.

20 Likes

Didn’t even think about heightmaps, and I myself had to experience the pain of making a plugin that uses Roblox lua and Java together in order to scan and generate. That’d be a brilliant time saver.

2 Likes

Oh boy!

I did this a long while ago using PHP.

imagecreatefrompng and imagecolorat are what you need if you want to do it how I did.

6 Likes

I get it via 3rd party server via HttpService

2 Likes