Thanks for testing chafari
Quote: " I only can see the whole painting area if I set 800*600 . If I let resolution 1024 * 768 I just see half of the painting area ?"
I would think that's an issue with machines that don't correctly display 1026*768 but il look into it
Quote: "Now when trying to load map ..program crash ."
not sure why, I now when I load a png image I make it a multiple of 2 ie 64*64 or 512*2 etc
I load them in where you see this code
//TO LOAD AN IMAGE ON STARTUP UNCOOMENT ONE OF THE HEIGHT FUNCTIONS AND DOHOUSEKEEPING FUNCTIONS
centreObjId=normalHeightFunction("logo4.png")
//centreObjId=smoothHeightFunction("map.png")
deletedObjects=dohousekeeping()
the problem may be that its not returning a centreObjId, but i thought i removed all those issues, the other thing
it may be is the drawing routine which i may delete yet and just make it an image loader, or perhaps your using to large a png
which is most likely the problem
I added a home function which centers the objects with "Home" key
// show all errors
SetErrorMode(2)
#constant screenwidth=1024
#constant screenheight=768
#constant fullscreen=0
#constant screenrate=0
#constant KEY_LEFT 37
#constant KEY_UP 38
#constant KEY_RIGHT 39
#constant KEY_DOWN 40
#constant KEY_A 65
#constant KEY_E 69
#constant KEY_Z 90
#constant KEY_M 77
#constant KEY_S 83
#constant KEY_L 76
#constant KEY_C 67
#constant KEY_HOME 36
// set window properties
SetWindowTitle( "map" )
SetWindowSize( screenwidth, screenheight, fullscreen )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( screenwidth, screenheight ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( screenrate, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
type _boxes
id
memID
x#
y#
z#
endtype
final_object as integer
global objnumber
colorWheelImg=createColorWheelImage(128)
colorWheelSpr=CreateSprite(colorWheelImg)
SetSpritePosition(colorWheelSpr,screenwidth-128,128)
drawImg=createDrawImage(126)
drawSpr=CreateSprite(drawImg)
SetSpritePosition(drawSpr,screenWidth-127,0)
frameImg=drawFrame(128)
frameSpr=createSprite(frameImg)
SetSpritePosition(frameSpr,screenWidth-128,0)
SetSpriteDepth(frameSpr,11)
global boxes as _boxes[]
//TO LOAD AN IMAGE ON STARTUP UNCOOMENT ONE OF THE HEIGHT FUNCTIONS AND DOHOUSEKEEPING FUNCTIONS
centreObjId=normalHeightFunction("logo4.png")
//centreObjId=smoothHeightFunction("map.png")
deletedObjects=dohousekeeping()
camerax#=32
cameray#=20
cameraz#=-85
do
//if getObjectExists(final_object) then MoveObjectLocalX(final_object,.05)
if GetRawKeyState(KEY_LEFT) then dec camerax#,.5
if GetRawKeyState(KEY_RIGHT) then inc camerax#,.5
if GetRawKeyState(KEY_UP) then dec cameray#,.5
if GetRawKeyState(KEY_DOWN) then inc cameray#,.5
if GetRawKeyState(KEY_A) then inc cameraz#,.5
if GetRawKeyState(KEY_Z) then dec cameraz#,.5
if GetRawKeyPressed(KEY_M)
//final_object=mergememblocks()
//if getObjectExists(final_object) then setobjectColor(final_object,0,200,0,255)
endif
if GetRawKeyPressed(KEY_S)
if GetObjectExists(final_object)=0
AGM_SaveObject("final.obj","final.mtl")
endif
endif
if GetRawKeyPressed(KEY_L)
if GetObjectExists(final_object)=0
final_object=LoadObject("final.obj")
SetObjectColor(final_object,random(1,255),random(1,255),random(1,255),255)
camerax#=32
cameray#=20
cameraz#=-19.5
endif
endif
if GetRawKeyPressed(KEY_E)
saveImage(drawImg,"map.png")
centreObjId=normalHeightFunction("map.png")
deletedObjects=dohousekeeping()
//SetCameraLookAt(1,GetObjectX(centreObjId),GetObjectY(centreObjId),GetObjectZ(centreObjId),1)
endif
if GetRawKeyPressed(KEY_C)
for num = boxes.length to 0 step -1
DeleteObject(boxes[num].id)
boxes.remove(num)
next num
DeleteAllObjects()
endif
if GetRawKeyPressed(KEY_HOME)
if getObjectExists(centreObjID)
xx#=GetObjectX(centreObjID)
yy#=GetObjectY(centreObjID)
zz#=GetObjectZ(centreObjID)
for num = boxes.length to 0 step -1
if GetObjectExists(boxes[num].id)
SetObjectPosition(boxes[num].id,getObjectX(boxes[num].id)-xx#,getObjectY(boxes[num].id)-yy#,getObjectZ(boxes[num].id)-zz#)
endif
next num
else
If GetObjectExists(final_object)
SetObjectPosition(final_object,0,0,0)
endif
endif
camerax#=0
endif
hit=GetSpriteHit(getPointerX(),getPointerY())
rem pick a colour from the screen
if getPointerState()>0 and hit=colorWheelSpr
col = pickColor(getPointerX(),getPointerY())
alpha = (col && 0xFF000000) >> 24
red = (col && 0x00FF0000) >> 16
green = (col && 0x0000FF00) >> 8
blue = col && 0x000000FF
endif
print("color=R" +str(red)+", G"+str(green)+", B"+str(blue)+", A"+str(alpha))
if getPointerState()>0 and hit=drawSpr
drawToImage(drawImg,getPointerX()-(screenwidth-128),128-getPointerY(),col)
endif
print(boxes.length)
print("Press Home to center")
print("Press C to clear")
print("Press E to Extrude")
print("Press S to save objects as one")
print("Press L to load object")
print("Camera X "+str(getCameraX(1)))
print("Camera Y "+str(getCameraY(1)))
print("Camera Z "+str(getCameraZ(1)))
Print("FPS "+str( ScreenFPS()) )
SetCameraPosition(1,camerax#,cameray#,cameraz#)
Sync()
loop
function smoothHeightFunction(filename$)
//top left front 0,9,18
//top right front 2,4,11
//top left back 8,14,16
//top right back 6,10,12
vertexLF as integer[2] = [0,9,18]
vertexRF as integer[2] = [2,4,11]
vertexLB as integer[2] = [8,14,16]
vertexRB as integer[2] = [6,10,12]
//bottom left front 1,19,20
//bottom right front 3,5,22
//bottom left back 15,17,21,24,25,26,27
//bottom right back 7,13,23,
box as _boxes
img = LoadImage(filename$)
imgmemblock = CreateMemblockFromImage(img)
local size as integer
width = GetMemblockInt(imgmemblock,0)
depth = GetMemblockInt(imgmemblock,4)
size=abs(width*depth)
for num=1 to size
boxes.insert(box)
next num
objnumber=0:lastheight#=0
for z=depth-1 to 0 step -1
for x= width-1 to 0 step -1
//check the x plane
xx=x+1:if xx>width-1 then xx=width-1
prevOffset = (12+((z * width) + xx) * 4) - 4
r=GetMemblockByte(imgmemblock,prevOffset)
g=GetMemblockByte(imgmemblock,prevOffset+1)
b=GetMemblockByte(imgmemblock,prevOffset+2)
a=GetMemblockByte(imgmemblock,prevOffset+3)
color#=(r+g+b)
prevHeight#=color#/100.0
xx=x-1:if xx<0 then xx=0
nextOffset = (12+((z * width) + xx) * 4) - 4
r=GetMemblockByte(imgmemblock,nextOffset)
g=GetMemblockByte(imgmemblock,nextOffset+1)
b=GetMemblockByte(imgmemblock,nextOffset+2)
a=GetMemblockByte(imgmemblock,nextOffset+3)
color#=(r+g+b)
nextHeight#=color#/100.0
boxes[objnumber].id=CreateObjectBox(1,1,1)
SetObjectPosition(boxes[objnumber].id,x, 0 ,-z)
SetObjectColor(boxes[objnumber].id,r,g,b,a)
boxes[objnumber].memID=CreateMemblockFromObjectMesh(boxes[objnumber].id,1)
for i = 0 to 2
SetMeshMemblockVertexPosition(boxes[objnumber].memID,vertexRF[i],GetMeshMemblockVertexX(boxes[objnumber].memID,vertexRF[i]),GetMeshMemblockVertexY(boxes[objnumber].memID,vertexRF[i])+prevHeight#,GetMeshMemblockVertexZ(boxes[objnumber].memID,vertexRF[i]))
SetMeshMemblockVertexPosition(boxes[objnumber].memID,vertexRB[i],GetMeshMemblockVertexX(boxes[objnumber].memID,vertexRB[i]),GetMeshMemblockVertexY(boxes[objnumber].memID,vertexRB[i])+prevHeight#,GetMeshMemblockVertexZ(boxes[objnumber].memID,vertexRB[i]))
SetMeshMemblockVertexPosition(boxes[objnumber].memID,vertexLF[i],GetMeshMemblockVertexX(boxes[objnumber].memID,vertexLF[i]),GetMeshMemblockVertexY(boxes[objnumber].memID,vertexLF[i])+nextHeight#,GetMeshMemblockVertexZ(boxes[objnumber].memID,vertexLF[i]))
SetMeshMemblockVertexPosition(boxes[objnumber].memID,vertexLB[i],GetMeshMemblockVertexX(boxes[objnumber].memID,vertexLB[i]),GetMeshMemblockVertexY(boxes[objnumber].memID,vertexLB[i])+nextHeight#,GetMeshMemblockVertexZ(boxes[objnumber].memID,vertexLB[i]))
next i
SetObjectMeshFromMemblock(boxes[objnumber].id,1,boxes[objnumber].memID)
//DeleteMemblock(memID)
//check the z plane
zz=z+1:if zz>depth-1 then zz=depth-1
prevOffset = (12+((zz * width) + x) * 4) - 4
r=GetMemblockByte(imgmemblock,prevOffset)
g=GetMemblockByte(imgmemblock,prevOffset+1)
b=GetMemblockByte(imgmemblock,prevOffset+2)
a=GetMemblockByte(imgmemblock,prevOffset+3)
color#=(r+g+b)
prevHeight#=color#/100.0
zz=z-1:if zz<0 then zz=0
nextOffset = (12+((zz * width) + xx) * 4) - 4
r=GetMemblockByte(imgmemblock,nextOffset)
g=GetMemblockByte(imgmemblock,nextOffset+1)
b=GetMemblockByte(imgmemblock,nextOffset+2)
a=GetMemblockByte(imgmemblock,nextOffset+3)
color#=(r+g+b)
nextHeight#=color#/100.0
//objects[objnumber].id=(CreateObjectBox(1,1,1))
SetObjectPosition(boxes[objnumber].id,x, 0 ,-z)
SetObjectColor(boxes[objnumber].id,r,g,b,a)
//boxes[objnumber].memID=CreateMemblockFromObjectMesh(boxes[objnumber].id,1)
for i = 0 to 2
SetMeshMemblockVertexPosition(boxes[objnumber].memID,vertexRF[i],GetMeshMemblockVertexX(boxes[objnumber].memID,vertexRF[i]),GetMeshMemblockVertexY(boxes[objnumber].memID,vertexRF[i])+prevHeight#,GetMeshMemblockVertexZ(boxes[objnumber].memID,vertexRF[i]))
SetMeshMemblockVertexPosition(boxes[objnumber].memID,vertexRB[i],GetMeshMemblockVertexX(boxes[objnumber].memID,vertexRB[i]),GetMeshMemblockVertexY(boxes[objnumber].memID,vertexRB[i])+nextHeight#,GetMeshMemblockVertexZ(boxes[objnumber].memID,vertexRB[i]))
SetMeshMemblockVertexPosition(boxes[objnumber].memID,vertexLF[i],GetMeshMemblockVertexX(boxes[objnumber].memID,vertexLF[i]),GetMeshMemblockVertexY(boxes[objnumber].memID,vertexLF[i])+prevHeight#,GetMeshMemblockVertexZ(boxes[objnumber].memID,vertexLF[i]))
SetMeshMemblockVertexPosition(boxes[objnumber].memID,vertexLB[i],GetMeshMemblockVertexX(boxes[objnumber].memID,vertexLB[i]),GetMeshMemblockVertexY(boxes[objnumber].memID,vertexLB[i])+nextHeight#,GetMeshMemblockVertexZ(boxes[objnumber].memID,vertexLB[i]))
next i
SetObjectMeshFromMemblock(boxes[objnumber].id,1,boxes[objnumber].memID)
//DeleteMemblock(memID)
if (width-1)/2=x and (depth-1)/2=z then centreObjId=boxes[objnumber].id
if (width-1)/2=x and (depth-1)=z then SetCameraPosition(1,getObjectX(boxes[objnumber].id),getObjectY(boxes[objnumber].id)+20,getObjectz(boxes[objnumber].id)-20)
inc objnumber:if objnumber =4095 then exitfunction centreObjID
next x
next z
endfunction centreObjID
function normalHeightFunction(filename$)
//top left front 0,9,18
//top right front 2,4,11
//top left back 8,14,16
//top right back 6,10,12
vertexLF as integer[2] = [0,9,18]
vertexRF as integer[2] = [2,4,11]
vertexLB as integer[2] = [8,14,16]
vertexRB as integer[2] = [6,10,12]
//bottom left front 1,19,20
//bottom right front 3,5,22
//bottom left back 15,17,21,24,25,26,27
//bottom right back 7,13,23,
box as _boxes
img = LoadImage(filename$)
imgmemblock = CreateMemblockFromImage(img)
local size as integer
width = GetMemblockInt(imgmemblock,0)
depth = GetMemblockInt(imgmemblock,4)
size=abs(width*depth)
for num=0 to size
boxes.insert(box)
next num
objnumber=0
for z=depth-1 to 1 step -1
for x= width-1 to 0 step -1
Offset = (12+((z * width) + x) * 4) - 4
r=GetMemblockByte(imgmemblock,Offset)
g=GetMemblockByte(imgmemblock,Offset+1)
b=GetMemblockByte(imgmemblock,Offset+2)
a=GetMemblockByte(imgmemblock,Offset+3)
color#=(r+g+b)
Height#=color#/100.0
boxes[objnumber].id=CreateObjectBox(1,1,1)
SetObjectPosition(boxes[objnumber].id,x, 0 ,-z)
SetObjectColor(boxes[objnumber].id,r,g,b,a)
boxes[objnumber].memID=CreateMemblockFromObjectMesh(boxes[objnumber].id,1)
for i = 0 to 2
SetMeshMemblockVertexPosition(boxes[objnumber].memID,vertexRF[i],GetMeshMemblockVertexX(boxes[objnumber].memID,vertexRF[i]),GetMeshMemblockVertexY(boxes[objnumber].memID,vertexRF[i])+Height#,GetMeshMemblockVertexZ(boxes[objnumber].memID,vertexRF[i]))
SetMeshMemblockVertexPosition(boxes[objnumber].memID,vertexRB[i],GetMeshMemblockVertexX(boxes[objnumber].memID,vertexRB[i]),GetMeshMemblockVertexY(boxes[objnumber].memID,vertexRB[i])+Height#,GetMeshMemblockVertexZ(boxes[objnumber].memID,vertexRB[i]))
SetMeshMemblockVertexPosition(boxes[objnumber].memID,vertexLF[i],GetMeshMemblockVertexX(boxes[objnumber].memID,vertexLF[i]),GetMeshMemblockVertexY(boxes[objnumber].memID,vertexLF[i])+Height#,GetMeshMemblockVertexZ(boxes[objnumber].memID,vertexLF[i]))
SetMeshMemblockVertexPosition(boxes[objnumber].memID,vertexLB[i],GetMeshMemblockVertexX(boxes[objnumber].memID,vertexLB[i]),GetMeshMemblockVertexY(boxes[objnumber].memID,vertexLB[i])+Height#,GetMeshMemblockVertexZ(boxes[objnumber].memID,vertexLB[i]))
next i
SetObjectMeshFromMemblock(boxes[objnumber].id,1,boxes[objnumber].memID)
//DeleteMemblock(memID)
if (width-1)/2=x and (depth-1)/2=z then centreObjId=boxes[objnumber].id
if (width-1)/2=x and (depth-1)=z then SetCameraPosition(1,getObjectX(boxes[objnumber].id),getObjectY(boxes[objnumber].id)+20,getObjectz(boxes[objnumber].id)-20)
inc objnumber:if objnumber =width*depth then exitfunction centreObjID
next x
next z
endfunction centreObjId
function dohousekeeping()
DeletedObjects=0
for num = boxes.length to 0 step -1
if GetObjectExists(boxes[num].id)
r=GetObjectColorRed(boxes[num].id)
b=GetObjectColorBLue(boxes[num].id)
g=GetObjectColorGreen(boxes[num].id)
if r+b+g<1
DeleteObject(boxes[num].id)
boxes.remove(num)
inc DeletedObjects
endif
endif
next num
endfunction DeletedObjects
Function AGM_SaveObject(filename$ as string,material$ as string)
fw = OpenToWrite(filename$)
WriteLine(fw,"#AGM Object - " + filename$)
WriteLine(fw,"#Exported with AppGameKit")
WriteLine(fw,"")
WriteLine(fw,"mtllib " + material$)
incrementalcounter=0
`number of material
m=0
//nor=0
//n=0
for t= boxes.length to 0 step-1
if GetObjectExists(boxes[t].id)
mesh = CreateMemblockFromObjectMesh(boxes[t].id,1)
` get object vertex quantity
verts= GetMemblockInt( mesh, 0 )
writeline(fw,"g ") //GROUP
`VERTEX
for i= 0 to verts -1
x#=GetMeshMemblockVertexX(mesh,i)
y#=GetMeshMemblockVertexy(mesh,i)
z#=GetMeshMemblockVertexz(mesh,i)
ox#=GetObjectWorldX(boxes[t].id)
oy#=GetObjectWorldY(boxes[t].id)
oz#=GetObjectWorldZ(boxes[t].id)
Writeline ( fw, " v " + str(x#+ox#)+ " "+str(y#+oy#)+ " "+str(z#+oz#))
next i
`TEXTURE VEERTICES
for i= 1 to verts
uu#=GetMeshMemblockVertexU( mesh, i )
vv#=GetMeshMemblockVertexV( mesh, i )
writeline(fw, " vt "+str(uu#)+" "+str(vv#))
next
` NORMALS
for i= 0 to verts -1
x#=GetMeshMemblockVertexnormalX(mesh,i)
y#=GetMeshMemblockVertexnormaly(mesh,i)
z#=GetMeshMemblockVertexnormalz(mesh,i)
Writeline ( fw, " vn " + str(x#)+ " "+str(y#)+ " "+str(z#))
next i
`FACES
inc m,1
Writeline ( fw,"usemtl Material.00"+str(m))
s=0 `reseting variable s
for i= 1 to verts-4
inc s,1
if s=3
n=n+1
nor=nor+4
writeline (fw, " f "+ str(n+1)+"/"+str(n+1)+"/"+str(nor) +" "+str(n) +"/"+str(n+2)+"/"+str(nor) +" "+str(n+2)+"/"+str(n)+"/"+str(nor) +" "+str(n+3)+"/"+str(n+3)+"/"+str(nor))
s=0
n=n+3
endif
next
DeleteMemblock(mesh)
endif
next t
CloseFile ( fw )
fw=OpenToWrite(material$)
for t= boxes.length to 0 step-1
if GetObjectExists(boxes[t].id)
Writeline ( fw,"newmtl Material.00"+str(t))
WriteLine(fw,"Kd " + str(GetObjectColorRed(boxes[t].id)/255.0) + " " + str(GetObjectColorGreen(boxes[t].id)/255.0) + " " + str(GetObjectColorBlue(boxes[t].id)/255.0))
DeleteObject(boxes[t].id)
DeleteMemblock(boxes[t].memID)
boxes.remove(t)
endif
next t
CloseFile(fw)
for num = boxes.length to 0 step -1
DeleteObject(boxes[num].id)
DeleteMemblock(boxes[num].memID)
boxes.remove(num)
next num
DeleteAllObjects()
endfunction
function createColorWheelImage(size#)
rem set up data
w = size#
cx = w/2
cy = w/2
rem create image
clearScreen()
setScissor(0,0,w,w)
`
spr = createSprite(0)
setSpriteSize(spr,1,1)
setSpriteAngle(spr,45)
`
ang# = 0
in# = 1.0/(size#/20.0)
repeat
rem set red value
r# = 0.0
v# = abs(wrap180(360-ang#))
if v#<120
if v#<=60
r# = 255.0
else
r# = (1.0-((v#-60)/60.0))*255
endif
endif
rem set green value
g# = 0.0
v# = abs(wrap180(120-ang#))
if v#<120
if v#<=60
g# = 255.0
else
g# = (1.0-((v#-60)/60.0))*255
endif
endif
rem set blue value
b# = 0.0
v# = abs(wrap180(240-ang#))
if v#<120
if v#<=60
b# = 255.0
else
b# = (1.0-((v#-60)/60.0))*255
endif
endif
rem paint colour spoke
fw# = w
tot = w*0.5 - 2
for i=1 to tot
rem set lightness
fi# = i
f# = fi#/(fw#*0.5)
if f#>0.5
f# = 1.0 - (f#-0.5)/0.5
thisR# = f#*r#
thisG# = f#*g#
thisB# = f#*b#
else
f# = 1.0 - f#/0.5
thisR# = r# + (255.0-r#)*f#
thisG# = g# + (255.0-g#)*f#
thisB# = b# + (255.0-b#)*f#
endif
rem paint sprite
setSpriteColor(spr,thisR#,thisG#,thisB#,255)
setSpritePositionByOffset(spr,cx+1+sin(ang#)*fi#,cy+1-cos(ang#)*fi#)
drawSprite(spr)
next
ang# = ang# + in#
until ang#>360.0
`
deleteSprite(spr)
`
img = getImage(0,0,w,w)
`
setScissor(0,0,getDeviceWidth(),getDeviceHeight())
clearScreen()
endfunction img
Function pickColor(X,Y)
rem prepare image grab area
clearScreen()
setScissor(X,Y,X+1,Y+1)
render()
rem get image
img = getImage(x,y,1,1)
rem create memblock
mem = createMemblockfromImage(img)
rem get memblock data
r = getMemblockbyte(mem,12)
g = getMemblockbyte(mem,13)
b = getMemblockbyte(mem,14)
rem tidy up
deletememblock(mem)
deleteimage(img)
setScissor(0,0,getDeviceWidth(),getDeviceHeight())
clearScreen()
color=makeColor(r,g,b)
endfunction color
function wrap180(v#)
while v#>180.0
v# = v# - 360.0
endwhile
while v#<-180.0
v# = v# + 360.0
endwhile
endfunction v#
function createDrawImage(size as integer)
rem create an ellipse that can be used as a sprite
SetClearColor(0,0,0)
ClearScreen()
Render()
DrawBox(0,0,size-1,size-1,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
//DrawBox(0,0,size-1,size-1,MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),0)
Swap()
img=getimage(0,0,size,size)
sync()
endfunction img
function createGreyWheelImage(size as integer)
rem create an ellipse that can be used as a sprite
SetClearColor(0,0,0)
ClearScreen()
Render()
DrawBox(0,0,size-1,size-1,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(255,255,255),MakeColor(255,255,255),1)
DrawBox(0,0,size-1,size-1,MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),0)
Swap()
img=getimage(0,0,size,size)
sync()
endfunction img
function drawFrame(size as integer)
SetClearColor(0,0,0)
ClearScreen()
Render()
//DrawBox(0,0,size-1,size-1,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawBox(0,0,size-1,size-1,MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),0)
Swap()
img=getimage(0,0,size,size)
sync()
endfunction img
function drawToImage(image as integer,x as integer,y as integer,col)
memblock=CreateMemblockFromImage(image)
width = GetMemblockInt(memblock, 0)
height = GetMemblockInt(memblock, 4)
A = (col && 0xFF000000) >> 24
R = (col && 0x00FF0000) >> 16
G = (col && 0x0000FF00) >> 8
B = col && 0x000000FF
if x<0 or x>width-1 then exitfunction
if y<0 or y>height -1 then exitfunction
R =R+ GetMemblockByte(memblock,12+(x*4)+((height-y)*4*width))
G =G+ GetMemblockByte(memblock,13+(x*4)+((height-y)*4*width))
B =B+ GetMemblockByte(memblock,14+(x*4)+((height-y)*4*width))
A =A+ GetMemblockByte(memblock,15+(x*4)+((height-y)*4*width))
if R>255 then R=255
if G>255 then G=255
if B>255 then B=255
if A>255 then A=255
SetMemblockByte(memblock,12+(x*4)+((height-y)*4*width),R) // Write Red
SetMemblockByte(memblock,13+(x*4)+((height-y)*4*width),G) // Write Green
SetMemblockByte(memblock,14+(x*4)+((height-y)*4*width),B) // Write Blue
SetMemblockByte(memblock,15+(x*4)+((height-y)*4*width),A) // Write Alpha full opaque (255)
CreateImageFromMemblock(image,memblock )
deleteMemblock(memblock)
endfunction
fubar