Unfortunately it's not working correctly I'm pretty sure drawingcolour and pixelcolour are not used in purebasic, but the rest of the code should be understood
The reason I'm trying to get this working is because they removed the usebuffer() command which messed up lots of cool post prossesing effects. So I'm hoping this will be a way around it
This is a code snipped, not functional
The process is to load an image into a buffer, perform some changes to the buffered image and display the image buffer
Code: Select all
; Load an image into a memory buffer
LoadImage(0, "image.bmp")
imageWidth = ImageWidth(0)
imageHeight = ImageHeight(0)
imageBufferSize = imageWidth * imageHeight * 4 ; 4 bytes per pixel (RGBA)
imageBuffer.l = AllocateMemory(imageBufferSize)
CopyImage(ImageOutput(0), imageBuffer)
; Create a new memory buffer to draw onto
drawingBuffer.l = CreateImage(imageWidth, imageHeight, #PB_Image_BGRA)
; Distort the image buffer by drawing onto the drawing buffer
For y = 0 To imageHeight - 1
For x = 0 To imageWidth - 1
; Calculate the new x and y coordinates based on a sine wave
newX = x + Sin(y / 10.0) * 10.0
newY = y + Sin(x / 10.0) * 10.0
; Get the pixel value from the original coordinates
pixel = PeekI(imageBuffer + (y * imageWidth + x) * 4)
; Set the pixel value at the new coordinates
DrawingColor(pixel)
DrawingPixel(newX, newY)
Next
Next
; Display the distorted image buffer
DrawingBuffer(drawingBuffer, 100, 100, imageWidth, imageHeight)
; Free the memory buffers
FreeMemory(imageBuffer)
FreeImage(drawingBuffer)