:noggin:
Im confused, i cant get the command to work: SAVESPRITE
notes:
1. ive tried with BMP, and get pink background.....and still its a screenshot for the internet, so bmp wont do either.
2. ive tried to fix the problem with settransparency command too(before and after SAVESPRITE )...further incorrect white background result.
note here:
SETTRANSPARENCY 0x000000
SAVESPRITE FileName$ , 100
SETTRANSPARENCY 0x8000ff
regardless of these transparencie colors(any used aside from these also), nothing seems to affect it proper.
This function below is the only version that properly produces the actual screen colors, in mspaint only.
And this is without using settransparency anywhere in the program.
i am using CLEARSCREEN 0x202020 in the header, before my main loop function call
@FUNCTION SYS_2d_SCREENSHOT:
STATIC ShotNum
LOCAL FileName$ = "Screenshots" + ShotNum + ".png"
INC ShotNum , 1
LOCAL ScreenSizeX , ScreenSizeY
GETSCREENSIZE ScreenSizeX , ScreenSizeY
GRABSPRITE 100 , 128 , 0 , 1024 , ScreenSizeY
SETCURRENTDIR(GETCURRENTDIR$()+"ScreenShots")
SAVESPRITE FileName$ , 100
SETCURRENTDIR("..")
ENDFUNCTION
[attachment deleted by admin]
MS Paint cant handle PNG transparencies and thus shows it as a white background. However, using a proper editor will show the transparent background and other items
[attachment deleted by admin]
MSPaint does show the proper background color.
The MSpaint screenshot is showing the correct colors.
Furthermore about mspaint, it can handle png transparencies...it is according to the selected background(right click color), when you save it.
Its everywhere ELSE, that doesnt show the correct color of the background.
The last screenshot i posted in the first message, is the ACTUAL result of SAVESPRITE, this is incorrect colored. (http://www.glbasic.com/forum/index.php?action=dlattach;topic=8401.0;attach=5290;image)
As you can see here in this image, a screenshot of the program running showing the proper color:
[attachment deleted by admin]
Do I understand you correctly that you do NOT want the picture to contain any transparent parts?
Hi moru
Yes , correct, i would like to make an exact screenshot.
The shot needs to be showing that grid below the object, the background color(the dark grey), and the object itself.
The problem is the background color, which is created by clearscreen 0x202020.
According to nik, this color is being published into the png as a transparent color.
I just had a thought - instead of grabbing the screen (which would grab the transparency), why not create a new screen and grab that (but put in a solid block of colour first to initialise it).
SAVEBMP and SAVESPRITE dosnet like alpha and you need to doing the code your self about alpha and transparency. I haven seen similar issues that the background was not the same you saw on screen. Howover you can use something code like that to fix it:
FUNCTION Image_Snap: File$
GLOBAL IDSNAP=0
LOCAL Width, Height, ok, a, r, g, b
LOCAL pix%[]
GETSCREENSIZE Width, Height
IF IDSNAP=0 THEN IDSNAP=GENSPRITE()
GRABSPRITE IDSNAP, 0, 0, Width, Height
IF SPRITE2MEM(pix[], IDSNAP)
LOCAL total=BOUNDS(pix[],0)
FOR i=0 TO total-1
r = bAND(pix[i], 0xff)
g = bAND(ASR(pix[i],8), 0xff)
b = bAND(ASR(pix[i],16), 0xff)
a = bAND(ASR(pix[i],24), 0xff)
a = 255
pix[i] = bOR(RGB(r,g,b), ASL(a, 24))
NEXT
IF MEM2SPRITE(pix, IDSNAP, Width, Height)
SAVESPRITE File$, IDSNAP
ENDIF
GRABSPRITE IDSNAP, 0, 0, 8, 8
ENDIF
ENDFUNCTION
The above use alpha as transparancy and remove it, which I use in Greedy Mouse but you have the idea. Howover in some chases alpha of course need to been included.
@nik
Thanks, works good. :good:
Its odd that SETTRANSPARENCY doesnt work with SAVESPRITE
This is why i think its a bug.
In order to use your idea i needed to implement it like this:
CLEARSCREEN Black
//stuff
IF DoShot=TRUE
DRAWRECT 128 , 0 , 1024 , ScreenSizeY, DarkGray //build background if taking a screeny
ELSE
CLEARSCREEN DarkGray
ENDIF
@space
Looks handy, Ill take that snip as food for thought because 1 extra comparison for the screeeny isnt going to be noticablly slower. :blink:
[attachment deleted by admin]
my code is not to been entended to use realtime, due the loop to remove alpha (its was to doing some screenshots from the game). You can as I wrote do something similar to add transparancy as well by yourself. Should been pretty easy to workaround.