I was experimenting with bge.texture.imageToArray() to retrieve the list of pixels/colors in the render, and it works fine. I am able to get a list of pixels with their RGB values. But it doesn’t seem like there is a way to do this “backwards”. Would it be possible to alter the pixel data and then pass it back into the respective texture?
Here’s what I want to do:
imageToArray(source,'RGB) > gives me a list of numbers > I want to alter these numbers somewhat > pass the data back into the image texture (or if I have to, make a new one?)
The reason I want to figure out how to do this is it would allow for manipulation of the texture coordinates and each pixel’s color using python, which could lead to some interesting results.
Here’s the section of code that I have so far:
def getPixelInfo(): obj = getObj("render01") #getObj is a function I wrote that calls an object in the scene by its name to make it easier #note these props were added in the gamelogic window to more easily change the camera/material while debugging matName = obj['matName'] fromCam = getObj(str(obj['fromCam'])) fromSce = getSce(str(obj['fromSce'])) # src = bge.texture.ImageRender(fromSce,fromCam) src.capsize = [320,240] src.background = [0,0,0,0] #world background (set to black) imageArray = bge.texture.imageToArray(src,'RGB') charArray = imageArray.to_list() print(charArray) #data in 1d array #alter the numbers in charArray # # # #then pass them back into the the texture image (or make a new one) - how??