get pixel color? set pixel color? from an image...

new BookmarkLockedFalling
davos1
Guest

Guest Avatar

Post by davos1 on Jan 12, 2009 1:32:27 GMT -5

Hi,
I am wondering if it is possible to allow to RB to get the color of a pixel in an image (#imageload) -and to update it-.

as an example -I had to use python image from PIL to solve it-
'load the image..

'then get the pixel values independently (c(1)=R,c(2)=G,c(3)=B)
c=pix(x,y)
'print the values
print "RGB";pix(x,y);
print "only R";c(0);"only G""; c(1);"only B";c(2)
'set a new value
pix(x,y)=(125,249,255)

getting the color of a pixel of a loaded image would add RB image manipulation capacity.

also, if that could be integrated with the #graphic (pixel to pixel transfer), or you could mix photos with graphics and save the mix or get info from the image loaded.

well , just dreamming, :)
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

Post by StefanPendl on Jan 12, 2009 2:04:28 GMT -5

You can already use the LOADGRAPHIC command to load an image into a graphics object as a background to draw onto, see the TinyImage example.

You can use the SET method to draw one individual pixel.

There is currently no support for getting the color of a pixel.

Check out the Graphics Overview in the RB help file ;)
[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
davos1
Guest

Guest Avatar