How to Copy CanvasBuffer to an ImageBuffer???

BlitzPlus Forums/BlitzPlus Programming/How to Copy CanvasBuffer to an ImageBuffer???

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I have this code and although the code compiles, it doesn't do what I want :)

I was hoping image_copy=CopyImage(CanvasBuffer(image)) would work too but it doesn't

Any ideas guys??? I'm a B+ newbie, but OK with B2D :)

;--- Load Image & Grab Properties---
image=LoadImage(file$)
MaskImage(image,255,0,255)
img_x#=ImageWidth(image)
img_y#=ImageHeight(image)

;--- Rescale Canvas & Image ---
FreeGadget canvas
canvas=CreateCanvas(0,0,ImageWidth(image),ImageHeight(image),panel)
scale#=(160/img_x#)*img_y#
SetGadgetShape canvas,0,0,160,scale#
SetSliderRange vslider,ClientHeight(panel),scale#

;--- Blit Results ---
SetBuffer CanvasBuffer(canvas)
DrawImage image,0,0
FlipCanvas (canvas)

;--- Copy Canvas to Array ---
Dim pixel(160,scale#)
LockBuffer CanvasBuffer(canvas)
For x_=0 To 159
For y_=0 To (scale#-1)
pixel(x,y)=ReadPixelFast(x,y)
Next
Next
UnlockBuffer CanvasBuffer(canvas)

;--- Copy Array to Temp Image ---
image_copy=CreateImage(160,scale#)
LockBuffer image_copy
For x_=0 To 159
For y_=0 To (scale#-1)
WritePixelFast x,y,pixel(x,y)
Next
Next
UnlockBuffer image_copy

;--- Debug Test Copy Results ---
SetBuffer CanvasBuffer(canvas)
Cls
DrawImage image_copy,0,0
FlipCanvas (canvas)