Small fixes for the screen capture.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1636 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-02-07 14:27:52 +00:00
commit b08c8991a5
3 changed files with 28 additions and 16 deletions

View file

@ -250,18 +250,18 @@ namespace Greenshot.Helpers {
info.rate = rate;
info.suggestedBufferSize = stride * height;
// create stream
if (Avi32.AVIFileCreateStream(file, out stream, ref info) != 0) {
throw new ApplicationException("Failed creating stream");
}
// describe compression options
Avi32.AVICOMPRESSOPTIONS options = new Avi32.AVICOMPRESSOPTIONS();
// create stream
if (Avi32.AVIFileCreateStream(file, out stream, ref info) != 0) {
throw new ApplicationException("Failed creating stream");
}
// uncomment if video settings dialog is required to show
int retCode = 0;
if (codec == null) {
int retCode = Avi32.AVISaveOptions( stream, ref options );
retCode = Avi32.AVISaveOptions( stream, ref options );
if (retCode == 0) {
LOG.Debug("Cancel clicked!");
return false;
@ -271,6 +271,7 @@ namespace Greenshot.Helpers {
options.quality = quality;
}
// create compressed stream
int retval = Avi32.AVIMakeCompressedStream(out streamCompressed, stream, ref options, IntPtr.Zero);
if (retval != 0) {
@ -320,6 +321,12 @@ namespace Greenshot.Helpers {
}
}
public void AddEmptyFrame() {
lock (this) {
position++;
}
}
/// <summary>
/// Add new frame to the AVI file.
/// </summary>

View file

@ -728,7 +728,7 @@ namespace Greenshot.Helpers {
}
if (screenCapture != null) {
screenCapture.RecordMouse = capture.CursorVisible;
if (screenCapture.Start(15)) {
if (screenCapture.Start(25)) {
return;
}
// User clicked cancel or a problem occured

View file

@ -45,6 +45,7 @@ namespace Greenshot.Helpers {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ScreenCaptureHelper));
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
private const int MAX_FRAMES = 500;
private const int ALIGNMENT = 8;
private IntPtr hWndDesktop = IntPtr.Zero;
private IntPtr hDCDesktop = IntPtr.Zero;
private IntPtr hDCDest = IntPtr.Zero;
@ -109,13 +110,13 @@ namespace Greenshot.Helpers {
LOG.InfoFormat("Starting recording rectangle {0}", recordingRectangle);
recordingSize = recordingRectangle.Size;
}
if (recordingSize.Width % 8 > 0) {
LOG.InfoFormat("Correcting width to be factor 8, {0} => {1}", recordingSize.Width, recordingSize.Width + (8-(recordingSize.Width % 8)));
recordingSize = new Size(recordingSize.Width + (8-(recordingSize.Width % 8)), recordingSize.Height);
if (recordingSize.Width % ALIGNMENT > 0) {
LOG.InfoFormat("Correcting width to be factor alignment, {0} => {1}", recordingSize.Width, recordingSize.Width + (ALIGNMENT - (recordingSize.Width % ALIGNMENT)));
recordingSize = new Size(recordingSize.Width + (ALIGNMENT - (recordingSize.Width % ALIGNMENT)), recordingSize.Height);
}
if (recordingSize.Height % 8 > 0) {
LOG.InfoFormat("Correcting Height to be factor 8, {0} => {1}", recordingSize.Height, recordingSize.Height + (8-(recordingSize.Height % 8)));
recordingSize = new Size(recordingSize.Width, recordingSize.Height + (8-(recordingSize.Height % 8)));
if (recordingSize.Height % ALIGNMENT > 0) {
LOG.InfoFormat("Correcting Height to be factor alignment, {0} => {1}", recordingSize.Height, recordingSize.Height + (ALIGNMENT - (recordingSize.Height % ALIGNMENT)));
recordingSize = new Size(recordingSize.Width, recordingSize.Height + (ALIGNMENT - (recordingSize.Height % ALIGNMENT)));
}
this.framesPerSecond = framesPerSecond;
// "P/Invoke" Solution for capturing the screen
@ -224,7 +225,11 @@ namespace Greenshot.Helpers {
msToNextCapture = MSBETWEENCAPTURES;
} else {
// Compensating
msToNextCapture = Math.Max(0, MSBETWEENCAPTURES - sleeptime);
do {
aviWriter.AddEmptyFrame();
sleeptime += MSBETWEENCAPTURES;
} while (sleeptime < 0);
msToNextCapture = sleeptime;
}
}
Cleanup();