CreateImage (set frames)
Monkey Forums/Monkey Programming/CreateImage (set frames)
| ||
Hi I can load in a tile set that is 640*640 with 100 frames of 64*64. When I want to create a tileset on the fly of 100 frames of 64*64 (from a pixel[] array),it fails saying the max width of 2048 has exceeded img = CreateImage(64,64,100) I'm assuming this creates an internal image of 6400x64, while my original image was 640x640 It would be nice in the CreateImage to specify either actual dimensions of the internal image or the xcount and ycount ie img = CreateImage(64,64,100,640,640) img = CreateImage(64,64,100,10,10) There may be another way of converting an image of 1 frame to 100 frames, but cant see one with the internal commands, so.. img = CreateImage(640,640) img.WritePixels(pixels,0,0,640,640) img.ConvertFrames(100) |
| ||
solved... extended mojo with setFrames.Method setFrames(iwidth,iheight,nframes,srcx,srcy,srcw,srch) ' turn off fullframe flags = flags & (Not FullFrame) ' resize frames frames = frames.Resize(nframes) width = iwidth height = iheight source=Null Local ix:=srcx,iy:=srcy For Local i=0 Until nframes If ix+width>srcw ix=0 iy+=height Endif If ix+width>srcw Or iy+height>srch Error "Image frame outside surface" Endif frames[i]=New Frame( ix+srcx,iy+srcy ) ix+=width Next ApplyFlags flags End usage img = CreateImage(300,300) img.setFrames(30,30,100) |
| ||
After writing the above last night, I've decided to use DrawImageRect instead on the larger single image |