Ok ok I read all the threads present in the forum about pixmap, something is clear now, but I have a problem with this
The goal is copy from a pixmap to another one...
Why I get only a black image?
'test copy image Graphics 640,480 Global load_image:TPixmap=LoadPixmap("gfx/world_2.png") If load_image.format<>PF_RGBA8888 Then load_image=ConvertPixmap( load_image,PF_RGBA8888 ) Copy(load_image) Flip WaitKey End Function Copy(pix:TPixmap) Local pix_dest:TPixmap=CreatePixmap(pix.width,pix.height,PF_RGBA8888) Local psource:Byte Ptr Local pdest:Byte Ptr psize=32*4*pix.height For k=0 To pix.width-32 Step 32 psource=PixmapPixelPtr(pix,k,0) 'pdest=PixmapPixelPtr(pix_Dest,pix.width-k,0) pdest=PixmapPixelPtr(pix_Dest,k,0) MemCopy(pdest,psource,psize) Next 'only for test image=ConvertToImage(pix_dest) DrawImage image,0,0 End Function Function ConvertToImage:timage(pix:TPixmap) Local size_x:Int=pix.width Local size_y:Int=Pix.height Local pdest:Byte Ptr Local psource:Byte Ptr psource=PixmapPixelPtr(pix,0,0) Local psize:Int=size_x*size_y*4 '4 bytes per pixel assuming RGBA8888 format pixmap temp_image:TImage=CreateImage(size_x,size_y,1,iflags|DYNAMICIMAGE) 'create dummy image in case we want to do realtime conversion between pixmaps and images/textures temp_pixmap:TPixmap=LockImage(temp_image,0,False,True) 'Lock our dummy image so we can draw to it pdest=PixmapPixelPtr(temp_pixmap,0,0) 'Set our destination pointer to the image's pixmap MemCopy(pdest,psource,psize) 'Copy the pixels from the pixmap in memory to the image/texture's pixmap UnlockImage(temp_image) 'Let the image be rendered now Return temp_image End Function
The goal is copy from a pixmap to another one...
Why I get only a black image?