- Joined
- Jan 2, 2020
- Messages
- 1,414
I was trying to debug something so I had to move from Android studio to take individual screenshots of each canvases.
Not sure if that was a good idea to try because it brought new bugs to my attention I think? I'm not sure but the behaviour perplexes me.
I tried to build a simple test-case this whole morning so others can see it.
let's see if I can explain it, there's some notes in the code too.
I have a couple of canvases that I tried to screenshot separately. That's for sure.
The save could not save more than one of the canvses. I can't really figure out how it picks out WHICH ONE it can save, but I would call it the "main". But what is the main canvas? So I thought, no, it's the last one that is flushed that is possible to save. So I flush the one i want to sav before call the screenshot. Nope, not quiet.
But now the screen goes black as soon as I flush something else. Wonderful.
So I tried to change the order of the flushes for a few hours and trying loading and creating graphics and see if it makes any difference.
I can tell that if you load graphics there's a chance it save it upside down but not always and I can't find the pattern when it does it.
But i noted what I found in the actual code, and I'm kind of lost. Instead of getting screenshots of the individual parts of my game I now
feel that I understand absolutely nothing how Cerberus works.
The only conclusion other than that is that, maybe there's deep bugs in .. graphics? I don't think it's the save? The code is minimal and it saves whatever Cerberus gives it? Because it works sometimes?! (If I only have one canvas in my whole game it sure works but that's the only time)
Everything is a mess right now. e.g. the Flushes of other canvases makes the display go black?! The saves ahve correct canvas sizes but the content is never correct if it is correct it is always just one, the rest are black or garbage. I never experienced this but I can't get it to work?!
EDIT
The wanted effect is to save a hand, a -redbox-with-a-dot, and a screenshot of both of those in the upper corner (without any upsidedown or garbage effects) and for the display not to go black because of flushing canvases, so I can feel safe about using multiple canvases. I'm trying to understand what I've done wrong..
Not sure if that was a good idea to try because it brought new bugs to my attention I think? I'm not sure but the behaviour perplexes me.
I tried to build a simple test-case this whole morning so others can see it.
let's see if I can explain it, there's some notes in the code too.
I have a couple of canvases that I tried to screenshot separately. That's for sure.
The save could not save more than one of the canvses. I can't really figure out how it picks out WHICH ONE it can save, but I would call it the "main". But what is the main canvas? So I thought, no, it's the last one that is flushed that is possible to save. So I flush the one i want to sav before call the screenshot. Nope, not quiet.
But now the screen goes black as soon as I flush something else. Wonderful.
So I tried to change the order of the flushes for a few hours and trying loading and creating graphics and see if it makes any difference.
I can tell that if you load graphics there's a chance it save it upside down but not always and I can't find the pattern when it does it.
But i noted what I found in the actual code, and I'm kind of lost. Instead of getting screenshots of the individual parts of my game I now
feel that I understand absolutely nothing how Cerberus works.
The only conclusion other than that is that, maybe there's deep bugs in .. graphics? I don't think it's the save? The code is minimal and it saves whatever Cerberus gives it? Because it works sometimes?! (If I only have one canvas in my whole game it sure works but that's the only time)
Everything is a mess right now. e.g. the Flushes of other canvases makes the display go black?! The saves ahve correct canvas sizes but the content is never correct if it is correct it is always just one, the rest are black or garbage. I never experienced this but I can't get it to work?!
EDIT
The wanted effect is to save a hand, a -redbox-with-a-dot, and a screenshot of both of those in the upper corner (without any upsidedown or garbage effects) and for the display not to go black because of flushing canvases, so I can feel safe about using multiple canvases. I'm trying to understand what I've done wrong..
Cerberus:
Strict
Import mojo2
Import brl.requesters
Import brl.filepath
Import saveImage
Function Main:Int()
New myApp()
Return 0
End
Class myApp Extends App
Field powerupRom : Image
Field powerupImage : Image
Field powerupCanvas : Canvas
Field bgImg : Image
Field bgCanvas : Canvas
Field myCanvas : Canvas
Field individualscreenshot : Bool = False
Method OnCreate:Int()
SetSwapInterval 1 ; SetUpdateRate 0
myCanvas = New Canvas()
powerupRom = Image.Load("powerup.png",0,0,0)
'
powerupImage = New Image(powerupRom.Width(),powerupRom.Height(),0,0,Image.Managed)
powerupCanvas = New Canvas(powerupImage)
powerupCanvas.Clear
powerupCanvas.DrawImage powerupRom,0,0
powerupCanvas.Flush
bgImg = New Image(64,64,0,0,Image.Managed)
bgCanvas = New Canvas(bgImg)
bgCanvas.Clear 1,0,0
bgCanvas.SetColor 0,0,1
bgCanvas.DrawOval 16,16,16,16
bgCanvas.Flush
Return 0
End
Method OnUpdate:Int()
If MouseDown(0) Then individualscreenshot = True
Return 0
End
Method OnRender:Int()
myCanvas.Clear
myCanvas.DrawImage powerupImage,0,0 ' draw powerup
myCanvas.DrawImage bgImg,64,0 ' draw red square with blue dot
' ----------------------------------------------------
' powerupCanvas.Flush ' uncommenting this line will make the screen go black
' if its enabled alone or last the file gets saved correctly, BUT the image will be upside down
' bgCanvas.Flush ' uncommenting this line will cause the screen go black
' if its enabled alone or last the file gets saved correctly
myCanvas.Flush ' as long as this line is activated and alone you will see a working screen
' and it will be saved correctly if its enabled alone (if others are activated it does not even matter if its last it still doesn't work)
' if it is activate alone then all other files will be saved as solid black
' Instructions : (uncomment one or two or three of the above lines before running)
' Click left mouse button to screeshoot all three canvases to individual files
' The saved files will always have the correct canvassizes but they will be black, empty, or filled with trash. Except when you follow the above comments.
' Some are upsidedown sometimes, as described above.
' ----------------------------------------------------
If individualscreenshot = True
individualscreenshot = False
Local file := RequestFile("Save file....", "Image Files:png,jpg,bmp;All Files:*", True)
Local ext:=filepath.ExtractExt(file).ToLower()
SavePNG(file, powerupCanvas) ' Canvas 1 (powerup) this does not work
SavePNG(file+"landscape.png", myCanvas) ' Canvas 2 this one works
SavePNG(file+"clouds.png", bgCanvas) ' Canvas 3 (clouds) this does not work
Endif
Return 0
End
End
Last edited: