GrabCanvas?
Monkey Forums/Monkey Programming/GrabCanvas?
| ||
Any way to draw to the screen and then grab and creat an image of it quickly? |
| ||
i would love this function but as far as i know it cant be done.I really hope im wrong and someone knows better. |
| ||
didn't mark add exactly this? ReadPixels()? |
| ||
Method grabforfade:Int() scrshot = CreateImage(SCREEN_WIDTH, SCREEN_HEIGHT) Local pixels:Int[] = New Int[SCREEN_WIDTH * SCREEN_HEIGHT] ReadPixels(pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) scrshot.WritePixels(pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) Return 0 End Obviously scrshot is whatever image you want this needs to be called from onrender() there is an example bit of code that utilises this method here in this thread |
| ||
awesome this works great just tested it. soooo glad i was wrong.Thanks |
| ||
Great thanks. im gonna use this to avoid drawing background sprites. im going to draw them once...grab an image of them and just display that instead! |
| ||
What about transparency? |
| ||
Check out the pixel perfect test code: http://www.monkeycoder.co.nz/Community/posts.php?topic=3488#36692 You need to specify a mask colour (black in this example). ' convert the mask colour (black) to alpha For Local i:Int=0 Until image.Width() * image.Height() Local argb:Int = pixels[i] Local a:Int = (argb Shr 24) & $ff Local r:Int = (argb Shr 16) & $ff Local g:Int = (argb Shr 8) & $ff Local b:Int = argb & $ff If a = 255 And r = 0 And g = 0 And b = 0 Then a = 0 argb = (a Shl 24) | (r Shl 16) | (g Shl 8) | b pixels[i] = argb End Next image.WritePixels(pixels, 0, 0, image.Width(), image.Height()) |
| ||
What I need is a function that can be fed an image and a list of 2d vectors (x,y) and return a single image of the images at all the vectors and any open squares will be transparent. That's what I NEED! XDFunction FuseImage:Image(image_file:String, vec_list:List<Vec2>) Local image:Image = LoadImage(image_file) For local v:Vec2 = Eachin vec_list DrawImage image, v.x, v.y Next Local this:Image = CreateImage(width, height) Local pixels:Int[] = New Int[width * height] ReadPixels(pixels,0,0,width,height) this.WritePixels(pixels,0,0,width,height) Return this End Function The above is pseudo code but OMG that would rawk! |