Hi Peter ,
i have fixed it , here is a working example
$ filename "PPM_Img_Ex.exe"
#include "..\..\inc\RTL32.inc"
include "sw.inc"
indexbase 0
Window 640,480,1
sys ppmHandle[128]
sys ppmWidth [128]
sys ppmHeight[128]
Function LoadFromMemPPM(sys MemPtr) as sys
sys h,j=3,co,mem,string sW,sH
byte ppm[16] at MemPtr
static sys id
if id <128 then inc id
if ppm[0]=0x50 and ppm[1]=0x36
while ppm[j] <> 0x20
sW += Chr ppm[j]
j +=1
wend
while ppm[j] <> 0x0A
sH += Chr ppm[j]
j +=1
wend
ppmWidth [id] = Val(sW)
ppmHeight[id] = Val(sH)
j +=1
while ppm[j] <> 0x0A
j +=1
wend
j +=1
mem = MemPtr+j
img=NewImage ppmWidth[id],ppmHeight[id]
for y=0 to ppmHeight[id]-1
for x=0 to ppmWidth[id]-1
z=(y*ppmWidth[id]+x)*3
r=Peek mem,z+0
g=Peek mem,z+1
b=Peek mem,z+2
SetImagePixel img,x,y,RGB(r,g,b)
next
next
Endif
Return img
End Function
sys p
embedfile "toy.ppm",p
p1 = LoadFromMemPPM p
p2 = LoadBmp "stern32.bmp",32
sys z
single v
while Key(27)=0
cls 255
ImageRect p1,300,100,256,256,0,0
ImageRect p1,0,0,256,256,0,0
DrawBmp p2,50,350,100,100,z
DrawBmp p2,150,350,100,100,z
DrawBmp p2,250,350,100,100,z
DrawBmp p2,350,350,100,100,z
DrawBmp p2,450,350,100,100,z
v +=.2
if v >=1
v=0
z +=1
if z=32 then z=0
endif
Sync
wend
Quit