[kinovea-dev] Re: Bug fix: Magnifier when exporting video

  • From: Joan <joan@xxxxxxxxxxx>
  • To: kinovea-dev@xxxxxxxxxxxxx
  • Date: Wed, 10 Feb 2010 21:25:10 +0100

Le 10/02/2010 16:24, Erik Larsson a écrit :
Hi,

Probably the best way to get deep in source code is to correct bugs! So....

In the branch:
http://svn.codingteam.net/kinovea/branches/erik.larsson/bug_fixes/0000164 at revision number 197 I have added a bug fix for Magnifier-bug reported at:
http://kinovea.org/bugs/view.php?id=164

Ps. I've not been able to create an account on the bug report system, hence the mail info!

/Erik

Hi,

Thank you for looking into this.

While I was looking at your modifications, I realised that there was some things I overlooked previously, so this will be a (much) longer mail than I anticipated.
Hopefully it will make some parts clearer.


1. GetOutputBitmap.
The parameter _bFlushDrawings tells us if the user wants the drawings to be permanently painted on the image.

This parameter is true when the user has selected "permanently paint key images data on the video".
It is also (forced) true when saving from Diaporama or Paused video dialog.

However, it is false when the user chooses "Save video only" in the main Save dialog. It could be debated, but I think that for the user, choosing this "Save video only" option means he wants to save the original video and not have drawings or anything on it. (it's how I programmed it anyway).

So I think the last condition should remain simply :
if (_bFlushDrawings)

Because if _bFlushDrawings is false, we don't want to paint the other drawings on the image just because the magnifier was enabled, and we don't even want to draw the magnifier either.

However, there is a catch :-)
With the current way things are working, if the user has enabled the magnifier but hasn't any key image, when he hits the save menu or button he will *not* be proposed the full Save dialog, only the simple one.
So we also need to correct that.

Similarly, for the first condition, if _bKeyframesOnly is true and we are not on a keyframe, we shouldn't call the painting routine.


So, several things to do:
a. In GetOutputBitmap, remove the tests on m_Magnifier.Mode. If the user wants the drawings (including magnifier) to be painted on, bFlushDrawing will be true. b. If the user has enabled magnifier and hits Save, we should display the full Save dialog, so he may eventually choose to "Permanently paint key images data", (even if he doesn't have any key images but only the magnifier).


2. Painting the magnifier in FlushDrawingsOnGraphics() instead of FlushOnGraphics()

As you noticed, the issue is that we don't have the image to draw (only a Graphics object extracted from it). I see you used the m_FrameServer.VideoFile.FrameList[] to get it back. But this will only work when the video is in "Analysis" mode. That is, when the frames of the video have actually been extracted to memory, in this array. You can play with the options in Preferences… > Play / Analyze > Switch to Analysis mode, to force a video to never switch to "Analysis" mode. (as if it was a long video)
In "Normal" mode, the frames stay on disc and are extracted on the fly.
Problem is, the magnifier actually needs the original image to draw it again on the graphics of itself.

So, how can we fix it ?
Maybe we could change GetOutputBitmap prototype to take the frame Bitmap itself (instead of the Graphics) and somehow pass it to the magnifier draw method along with its Graphics object.
(We may have to call the magnifier.draw inside GetOutputBitmap.)


Let me know what you think, and if anything is unclear or sounds wrong.

Thank you !
Joan.


Other related posts: