Best method to work with pixels

BlitzMax Forums/BlitzMax Programming/Best method to work with pixels

I found that the quickest way to work with pixels is to use PixmapPixelPtr and set the pixmap format to one that is easy to work with. this will give you the memory location of a pixel. so that

pixmap:tpixmap = createpixmap(100,100,PF_BGRA8888)
p:byte ptr = pixmappixelptr(pixmap,0,0)

' get RGB
b:int = p[0]
g:int = p[1]
r:int = p[2]

' set to orange
p[0] = 0
p[1] = 128
p[2] = 255


edit - got RGB the right way round now