You cannot edit TImages directly, you will have to use pixmaps. But you can easily convert a pixmap to an image.
pMap:TPixmap = createpixmap(256,256)
img:TImage = loadimage(pMap)
You can directly edit pixmaps either by using write/readpixels commands, or getting the pointer to the pixmap and access the rgba values directly. You can convert an image to a pixmap by using the LockImage() command.
Here is an example of an invert filter function.
Graphics 1024,768
Local sourceImg:TImage = LoadImage("testimage.png",0)
Local destImg:TImage = invertFilter(sourceImg)
Cls
DrawImage(sourceImg,0,0)
DrawImage(destImg,256,0)
Flip
WaitKey()
End
Function invertFilter:TImage(source:TImage)
Local sourcePixmap:TPixmap = LockImage(source)
Local sourcePixmapPtr:Byte Ptr = PixmapPixelPtr(sourcePixmap,0,0)
Local tmpPixmap:TPixmap = CopyPixmap(sourcePixmap)
Local tmpPixmapPtr:Byte Ptr = PixmapPixelPtr(tmpPixmap,0,0)
Local x:Int,y:Int
Local r:Int,g:Int,b:Int
Local w:Int = tmpPixmap.width
Local h:Int = tmpPixmap.height
For x = 0 To w-1
For y = 0 To h-1
tmpPixmapPtr[x*4+y*4*w] = 255-sourcePixmapPtr[x*4+y*4*w] 'red
tmpPixmapPtr[x*4+y*4*w+1] = 255-sourcePixmapPtr[x*4+y*4*w+1] 'green
tmpPixmapPtr[x*4+y*4*w+2] = 255-sourcePixmapPtr[x*4+y*4*w+2] 'blue
tmpPixmapPtr[x*4+y*4*w+3] = sourcePixmapPtr[x*4+y*4*w+3] 'alpha
Next
Next
Local tmpImage:TImage = LoadImage(tmpPixmap)
Return tmpImage
End Function