This code is a Scale2x routine programed only in Free Basic using high level language code optimized and Free Basic graphic library.
Sub copyx2(x As Short, y As Short, spr As Any Ptr, scr As Any Ptr)
Dim As Integer w, h, size
Dim As Integer pitch, bypp
Dim As Any Ptr pixels, pixelsx, pixelsy
ImageInfo( spr, w, h, bypp, pitch, pixels )
Dim As Integer sw, sh
Dim As Integer spitch, sbypp
Dim As Any Ptr spixels, spixelsx, spixelsy
If scr <> 0 Then
ImageInfo( scr, sw, sh, sbypp, spitch, spixels )
Else
Screeninfo sw, sh, , sbypp, spitch
spixels = Screenptr()
EndIf
Dim As UInteger Ptr spixpointer1, spixpointer2, spixpointer3, spixpointer4
Dim pixpointer As UInteger Ptr
Dim As Integer i, j
spixels += x*sbypp + y*spitch
pixelsy = pixels
spixelsy = spixels
For i=0 To h-1 Step 1
spixelsx = spixelsy
pixelsx = pixelsy
For j=0 To w-1 Step 1
pixpointer = pixelsx
spixpointer1 = spixelsx
spixpointer2 = spixelsx+sbypp
spixpointer3 = spixelsx+spitch
spixpointer4 = spixelsx+sbypp+spitch
*spixpointer1 = *pixpointer
*spixpointer2 = *pixpointer
*spixpointer3 = *pixpointer
*spixpointer4 = *pixpointer
spixelsx = spixelsx+sbypp+sbypp
pixelsx = pixelsx+bypp
Next j
spixelsy = spixelsy+spitch+spitch
pixelsy = pixelsy+pitch
Next i
End Sub
Simply to get high speed use "sbypp" and "spitch" for the target image and "bypp", "pitch" for source image. Adding this to target and source pointers. "sbypp" and "bypp" in the inner loop (columns) and "spitch" and "pitch" in the outter loop (rows).