Scolring - Forum

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.

#1 1-May-2017 15:22:34

jasolo
Member
Registered: 2-Apr-2017
Posts: 20

Date format of Screenshot PlugIT

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

#2 1-May-2017 17:01:02

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Date format of Screenshot PlugIT

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

#3 13-May-2017 10:49:14

jasolo
Member
Registered: 2-Apr-2017
Posts: 20

Re: Date format of Screenshot PlugIT

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

#4 13-May-2017 12:52:11

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Date format of Screenshot PlugIT

well done smile

Offline

#5 13-May-2017 14:00:37

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: Date format of Screenshot PlugIT

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

#6 13-May-2017 17:36:08

jasolo
Member
Registered: 2-Apr-2017
Posts: 20

Re: Date format of Screenshot PlugIT

Good to know the function alternative, iri.

I've found that the files saved as ".png.jpg" are jpgs with 75% quality, not pngs. yikes 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

#7 13-May-2017 17:51:47

jasolo
Member
Registered: 2-Apr-2017
Posts: 20

Re: Date format of Screenshot PlugIT

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

#8 13-May-2017 18:01:11

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Date format of Screenshot PlugIT

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

#9 13-May-2017 20:22:26

jasolo
Member
Registered: 2-Apr-2017
Posts: 20

Re: Date format of Screenshot PlugIT

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. sad

Offline

#10 13-May-2017 20:58:20

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Date format of Screenshot PlugIT

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 hmm)

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

#11 13-May-2017 22:09:22

jasolo
Member
Registered: 2-Apr-2017
Posts: 20

Re: Date format of Screenshot PlugIT

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

#12 13-May-2017 23:37:14

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Date format of Screenshot PlugIT

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

#13 14-May-2017 00:33:38

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Date format of Screenshot PlugIT

Offline

#14 14-May-2017 11:47:35

jasolo
Member
Registered: 2-Apr-2017
Posts: 20

Re: Date format of Screenshot PlugIT

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

#15 14-May-2017 14:11:43

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Date format of Screenshot PlugIT

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

#16 14-May-2017 15:21:52

jasolo
Member
Registered: 2-Apr-2017
Posts: 20

Re: Date format of Screenshot PlugIT

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

#17 14-May-2017 15:56:39

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Date format of Screenshot PlugIT

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

#18 13-Mar-2020 12:34:34

shahbiz8
Member
From: Malaysia
Registered: 25-Feb-2016
Posts: 340

Re: Date format of Screenshot PlugIT

How to screenshot with alpha background?

Offline

#19 13-Mar-2020 14:09:50

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Date format of Screenshot PlugIT

Hello,

you just have to check the "use transparent background" option

Offline

#20 14-Mar-2020 03:53:45

shahbiz8
Member
From: Malaysia
Registered: 25-Feb-2016
Posts: 340

Re: Date format of Screenshot PlugIT

Ok thank you smile

Offline

Board footer

Powered by FluxBB