Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology
Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered
You are not logged in.
Pages: 1
The file name of the image saved with the Screenshot PlugIT is "mon_may_01_15-55-10_2017" when the date is "Monday May 1, 2017 15:55:10". I would prefer "20170401_155510", shorter and better for sorting. Can I use another date format?
Offline
hello, for now the is the default behavior, if you want options for this in the plugit please add a feature request on http://redmine.scolring.org
tell me if you can't get the account email on registration (check spam first)
Offline
My app have to be finished in less than two weeks so I have modified the code of the Screenshot PlugIT. In cscreenshot.pkg I've replaced the line:
let strcatn filePrefix::(strtrim strreplace (strreplace (ctime time) " " "_") ":" "-")::(if only3d then ".png" else ".jpg")::nil -> file in
by these ones:
let (localtime time) -> [seconds minutes hours day month year wd yd] in
let strcatn filePrefix::(itoa year)::(if month<10 then "0" else "")::(itoa month)::(if day<10 then "0" else "")::(itoa day)::"_"::(if hours<10 then "0" else "")::(itoa hours)::(if minutes<10 then "0" else "")::(itoa minutes)::(if seconds<10 then "0" else "")::(itoa seconds)::(if only3d then ".png.jpg" else ".jpg")::nil -> file in
It's my first time with Scol code, so surely there is a better code to do the same. I have also changed the extension string ".png" to ".png.jpg" because many Android galleries don't detect PNGs but they are capable of showing them with the jpg extension (I don't know the reason, but it works).
Offline
Your code is correct.
Several different ways exist for this. Here, i use functions and sprintf :
fun getZeroIfAny (iData)=
strcat if iData < 10 then "0" else "" itoa iData;;
fun getOnly3d ()=
if only3d then ".png.jpg" else ".jpg";;
fun cbTakeShot (inst, from, action, param, rep, p) =
...
let sprintf "%s%d%s%s_%s%s%s%s"
[filePrefix // %s
year // %d
getZeroIfAny month // %s
getZeroIfAny day // %s
getZeroIfAny hours // %s
getZeroIfAny minutes // %s
getZeroIfAny seconds // %s
getOnly3d] // %s
-> file in
...
It may be more readable but this is subjective.
(i don't check its validity, it might be easily adapted)
Offline
Good to know the function alternative, iri.
I've found that the files saved as ".png.jpg" are jpgs with 75% quality, not pngs. I've read in this forum that png was used because 3D is RGBA, I think, but it seems that the program uses the format indicated in the extension. Any possibility to change by code the quality used to save jpgs?
Offline
Well, the problem of the android viewers with the pngs was due to the path of the file prefix: "%pictures%/screenshots/myprefix". Just reducing to one folder "%pictures%/myprefix" solves the problem. Anyway I would prefer jpgs with higher quality instead of pngs because of the smaller size.
Offline
what you can do is save the file in png format and then read the file and save it again with jpeg functions.
anyway png is a zipped format you get better size with better quality.
if (SO3BufferWriteContent viewstr.V3D_buffer (_getmodifypack file)) == nil then nil else
(
let _LDalphaBitmap _channel (_checkpack file) -> abmp in
let _GETalphaBitmaps abmp -> [bmp alpha] in
(
_SAVEjpeg bmp (_getmodifypack (strcat file ".jpg")) 90;
//delete png file
_deletepack (_checkpack file);
//free loaded bmp
_DSalphaBitmap abmp;
);
SendPluginEvent inst "Saved" file nil;
);
Offline
I've replaced the original code
if (SO3BufferWriteContent viewstr.V3D_buffer (_getmodifypack file)) == nil then nil else
SendPluginEvent inst "Saved" file nil;
with yours but it doesn't work. When the extension code is the original
if only3d then ".png" else ".jpg"
the result is a png. And with the trick ".png.jpg" a jpg 75% quality is created. It's the same as before.
Offline
The code I show below should
- create the png file
- then load it as a bitmap
- save it as jpg with 90% quality
- delete png file and bitmap
so you must keep the png extension as in the original code
(I don't remember if I managed the _SAVEjpeg function on android )
you can also try with
if (SO3BufferWriteContent viewstr.V3D_buffer (_getmodifypack file)) == nil then nil else
(
let _LDalphaBitmap _channel (_checkpack file) -> abmp in
let _GETalphaBitmaps abmp -> [bmp alpha] in
(
_BTSAVEbitmap bmp (_getmodifypack (strcat file ".jpg")); // jpg 95%
//delete png file
_deletepack (_checkpack file);
//free loaded bmp
_DSalphaBitmap abmp;
);
SendPluginEvent inst "Saved" file nil;
);
Offline
I'm trying first in Windows but I've also tried with Android. Using _BTSAVEbitmap gives also a png.
The code after all these changes, in case I've made some mistake:
fun cbTakeShot(inst, from, action, param, rep, p) =
let V3DgetSessionView c3dXsession -> viewstr in
let p -> [filePrefix only3d] in
let (localtime time) -> [seconds minutes hours day month year wd yd] in
let strcatn filePrefix::(itoa year)::(if month<10 then "0" else "")::(itoa month)::(if day<10 then "0" else "")::(itoa day)::"_"::(if hours<10 then "0" else "")::(itoa hours)::(if minutes<10 then "0" else "")::(itoa minutes)::(if seconds<10 then "0" else "")::(itoa seconds)::(if only3d then ".png" else ".jpg")::nil -> file in
(
if (only3d) then
(
if (SO3BufferWriteContent viewstr.V3D_buffer (_getmodifypack file)) == nil then nil else
(
let _LDalphaBitmap _channel (_checkpack file) -> abmp in
let _GETalphaBitmaps abmp -> [bmp alpha] in
(
_BTSAVEbitmap bmp (_getmodifypack (strcat file ".jpg")); // jpg 95%
//delete png file
_deletepack (_checkpack file);
//free loaded bmp
_DSalphaBitmap abmp;
);
SendPluginEvent inst "Saved" file nil;
); 0;
)
else
(
let _GETscreenSize -> [sw sh] in
let _FILLbitmap _CRbitmap _channel sw sh 0x0 -> bmp in
let _CAPTUREscreen bmp 0 0 sw sh 0 -> bmp in
(
_SAVEjpeg bmp _getmodifypack file 75;
_DSbitmap bmp;
SendPluginEvent inst "Saved" file nil;
);
0;
);
);
0;;
Offline
Ok after a quick check I found that the %picture% and %documents% are not managed in _checkpack and deletepack
here a workaround :
but for now you will have both png and jpg file ^^
I'm correcting the missing features in _checkpack and deletepack function to allow picture and document path
let _getmodifypack file -> wfile in
if (SO3BufferWriteContent viewstr.V3D_buffer wfile) == nil then nil else
(
let _BTLOADbitmap _channel _WtoP wfile -> bmp in
(
_BTSAVEbitmap bmp (_getmodifypack (strcat file ".jpg")); // jpg 95%
//delete png file won't work files outside scol partiton are forgiven
//_deletepack _WtoP wfile;
//free loaded bmp
_DSbitmap bmp;
);
SendPluginEvent inst "Saved" file nil;
);
0;
Offline
Done for future releases
Offline
The last solution works, but I don't want two pictures. I'm back to my original question, when the ".png.jpg" trick creates a jpg with 75% quality. I don't know what function is the responsible, but maybe it has the quality as parameter and it's called with the 75 value or the default value is 75. In that case I would want to change it to 90 or 95 (good quality for jpg and smaller size than png).
Offline
this is because of SO3BufferWriteContent that change the image format depending of the file extension.
The jpeg compression is also hardcoded so you can't change it here. sorry you'll have to wait for future release or beta ^^
And since I've updated Ogre to the last default branch there a lot of broken things for multi platform I have to correct before a release.
Offline
OK. Another question about the screenshots. The orientation of my android app is landscape and all the captured images are also landscape. But people could take a shot in portrait and then they'll see the image is rotated (landscape instead of portrait). I suppose the solution is to use the Orientation sensor plugit whose Z value is (-45, 45) in landscape, (-135, -45) in portrait and so on. But I don't know what element to change with that info ¿the active camera?
Offline
The screenshot take the 3D buffer size, in portrait mode it should be portrait also but you must export the app in portrait mode.
The orientation sensor do not rotate the 3D view it could act weird if so.
Offline
How to screenshot with alpha background?
Offline
Ok thank you
Offline
Pages: 1