Skip to content

Commit

Permalink
new : can define snapshot filename
Browse files Browse the repository at this point in the history
  • Loading branch information
pubpub-zz committed Dec 21, 2021
1 parent 5116cd3 commit 099d1ea
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 82 deletions.
3 changes: 2 additions & 1 deletion ppInk/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ AltTab_Start = False

Fading_Time= 0.1

# The folder that snapshots are saved to
# The folder that snapshots are saved to ; use the expansion system
Snapshot_Path = %USERPROFILE%/Pictures/gInk/
Snapshot_File = $YYYY$-$MM$-$DD$ $H$-$M$-$S$.png

# Engage directly Capture when opening toolbar (from hotkey/floating window/tray icon)
Open_Into_Snap = False
Expand Down
29 changes: 24 additions & 5 deletions src/FormDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ public uint Lnext()

public void SnapShot(Rectangle rect,string dest="")
{
string snapbasepath = Root.SnapshotBasePath;
snapbasepath = Environment.ExpandEnvironmentVariables(snapbasepath);
string snapbasepath = Root.ExpandVarCmd(Root.SnapshotBasePath,0,0,0,0);
//snapbasepath = Environment.ExpandEnvironmentVariables(snapbasepath);
//if (Root.SnapshotBasePath == "%USERPROFILE%/Pictures/gInk/")
if (!System.IO.Directory.Exists(snapbasepath))
System.IO.Directory.CreateDirectory(snapbasepath);
Expand Down Expand Up @@ -872,14 +872,33 @@ public void SnapShot(Rectangle rect,string dest="")
Clipboard.SetImage(tempbmp);
//DateTime now = DateTime.Now;
//string nowstr = now.Year.ToString() + "-" + now.Month.ToString("D2") + "-" + now.Day.ToString("D2") + " " + now.Hour.ToString("D2") + "-" + now.Minute.ToString("D2") + "-" + now.Second.ToString("D2");
string savefilename = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss'.png'");
Root.SnapshotFileFullPath = snapbasepath + savefilename;
string savefilename = Root.ExpandVarCmd(Root.SnapshotFileTemplate, 0, 0, 0, 0);//DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss'.png'");
Root.SnapshotFileFullPath = snapbasepath + savefilename;

if (dest == "")
dest = Root.SnapshotFileFullPath;
else
dest = Environment.ExpandEnvironmentVariables(dest);
tempbmp.Save(dest, System.Drawing.Imaging.ImageFormat.Png);

ImageFormat ifo=null;
switch(System.IO.Path.GetExtension(dest).ToLower())
{
case ".png": ifo = ImageFormat.Png;break;
case ".jpg":
case ".jpeg": ifo = ImageFormat.Jpeg; break;
case ".bmp": ifo = ImageFormat.Bmp; break;
case ".emf": ifo = ImageFormat.Emf; break;
case ".exf":
case ".exif": ifo = ImageFormat.Exif; break;
case ".tif":
case ".tiff": ifo = ImageFormat.Tiff; break;
case ".wmf": ifo = ImageFormat.Wmf; break;
case ".gif": ifo = ImageFormat.Gif; break;
}
if(ifo==null)
tempbmp.Save(dest);
else
tempbmp.Save(dest, ifo);

tempbmp.Dispose();

Expand Down
Loading

0 comments on commit 099d1ea

Please sign in to comment.