コード例 #1
0
        private void DrawWaveform(
            Graphics g,
            VidkaProj proj,
            VidkaFileMapping projMapping,
            VidkaClipVideo vclip,
            int x1, int y1, int clipw, int cliph,
            double secStart, double secEnd)
        {
            // TODO: tmp!!! please use a cache or something u idiot, dont read the f*****g file on every paint
            string waveFile = projMapping.AddGetWaveFilenameJpg(vclip.FileName);

            if (File.Exists(waveFile))
            {
                Bitmap bmpWave = imgCache.getWaveImg(waveFile);                         //Image ot
                var    xSrc1   = (int)(bmpWave.Width * secStart / vclip.FileLengthSec); //TODO: this
                var    xSrc2   = (int)(bmpWave.Width * secEnd / vclip.FileLengthSec);
                srcRect.X       = xSrc1;
                srcRect.Width   = xSrc2 - xSrc1;
                srcRect.Y       = 0;
                srcRect.Height  = bmpWave.Height;                //TODO: use constant from Ops
                destRect.X      = x1;
                destRect.Y      = y1;
                destRect.Width  = clipw;
                destRect.Height = cliph;
                g.DrawImage(bmpWave, destRect: destRect, srcRect: srcRect, srcUnit: GraphicsUnit.Pixel);
            }
        }
コード例 #2
0
ファイル: DrawOp.cs プロジェクト: liulaojian/VidkaEditor
 public DrawOp(IVidkaOpContext context, ImageCacheManager imageMan)
 {
     this.context  = context;
     this.imgCache = imageMan;
     if (context != null)
     {
         dimdim      = context.Dimdim;
         fileMapping = context.FileMapping;
         uiObjects   = context.UiObjects;
     }
 }
コード例 #3
0
        /// <param name="secStart">needs to be in seconds to figure out which thumb</param>
        /// <param name="len">needs to be in seconds to figure out which thumb</param>
        private void DrawClipBitmaps(
            Graphics g,
            VidkaProj proj,
            VidkaFileMapping projMapping,
            VidkaClipVideo vclip,
            int x1, int y1, int clipw, int clipvh,
            double secStart, double len)
        {
            string thumbsFile = projMapping.AddGetThumbnailFilename(vclip.FileName);
            //if (!File.Exists(thumbsFile))
            //	return;
            //Image origThumb = System.Drawing.Image.FromFile(thumbsFile, true);
            //var bmpThumb = new Bitmap(origThumb);
            var heightForThumbs = Math.Max(clipvh - 2 * THUMB_MARGIN_Y, ThumbnailTest.ThumbH);
            var thumbPrefWidth  = heightForThumbs * ThumbnailTest.ThumbW / ThumbnailTest.ThumbH;
            var howManyThumbs   = (clipw - THUMB_MARGIN) / (thumbPrefWidth + THUMB_MARGIN);

            if (howManyThumbs == 0)
            {
                howManyThumbs = 1;
            }
            var xCenteringOffset = (clipw - howManyThumbs * (thumbPrefWidth + THUMB_MARGIN)) / 2;

            for (int i = 0; i < howManyThumbs; i++)
            {
                //DrawVideoThumbnail(
                //	g: g,
                //	bmpAll: bmpThumb,
                //	timeSec: secStart + (i + 0.5) * len / howManyThumbs,
                //	xCenter: x1 + xCenteringOffset + i * (thumbPrefWidth + THUMB_MARGIN) + (thumbPrefWidth + THUMB_MARGIN) / 2,
                //	yCenter: y1 + clipvh / 2,
                //	preferredWidth: thumbPrefWidth,
                //	maxWidth: clipw);
                var timeSec    = secStart + (i + 0.5) * len / howManyThumbs;
                var imageIndex = (int)(timeSec / ThumbnailTest.ThumbIntervalSec);
                DrawVideoThumbnail(
                    g: g,
                    filenameAll: thumbsFile,
                    index: imageIndex,
                    xCenter: x1 + xCenteringOffset + i * (thumbPrefWidth + THUMB_MARGIN) + (thumbPrefWidth + THUMB_MARGIN) / 2,
                    yCenter: y1 + clipvh / 2,
                    preferredWidth: thumbPrefWidth,
                    maxWidth: clipw);
            }
            //bmpThumb.Dispose();
            //origThumb.Dispose();
        }
コード例 #4
0
 public DragAndDropManager(IVideoShitbox editor, VidkaProj proj, VidkaFileMapping fileMapping)
 {
     this.editor      = editor;
     Proj             = proj;
     Mode             = DragAndDropManagerMode.None;
     _draggies        = new List <DragAndDropMediaFile>();
     outstandingVideo = new List <VidkaClipVideoAbstract>();
     outstandingAudio = new List <VidkaClipAudio>();
     metaGenerator    = new MetaGeneratorInOtherThread(fileMapping);
     //metaGenerator.OneItemFinished += metaGenerator_OneItemFinished;
     //metaGenerator.MetaGeneratorDone += metaGenerator_MetaGeneratorDone;
     metaGenerator.HereIsSomeTextForConsole += genericListener_AppendToConsole;
     metaGenerator.MetaReady            += metaGenerator_MetaReady;
     metaGenerator.ThumbnailsReady      += metaGenerator_ThumbReady;
     metaGenerator.WaveformReady        += metaGenerator_WaveReady;
     metaGenerator.PleaseUnlockThisFile += metaGenerator_PleaseUnlockThisFile;
 }
コード例 #5
0
 public DragAndDropManager(IVideoEditor editor, VidkaProj proj, VidkaFileMapping fileMapping)
 {
     this.editor      = editor;
     Proj             = proj;
     Mode             = DragAndDropManagerMode.None;
     _draggies        = new List <DragAndDropMediaFile>();
     outstandingVideo = new List <VidkaClipVideo>();
     outstandingAudio = new List <VidkaClipAudio>();
     EXT_video        = Settings.Default.FileExtensionsVideo.Split('|');
     EXT_audio        = Settings.Default.FileExtensionsAudio.Split('|');
     metaGenerator    = new MetaGeneratorInOtherThread(fileMapping);
     //metaGenerator.OneItemFinished += metaGenerator_OneItemFinished;
     //metaGenerator.MetaGeneratorDone += metaGenerator_MetaGeneratorDone;
     metaGenerator.HereIsSomeTextForConsole += genericListener_AppendToConsole;
     metaGenerator.MetaReady       += metaGenerator_MetaReady;
     metaGenerator.ThumbnailsReady += metaGenerator_ThumbReady;
     metaGenerator.WaveformReady   += metaGenerator_WaveReady;
 }
コード例 #6
0
        private void drawVideoClip(Graphics g,
                                   VidkaClipVideo vclip,
                                   long curFrame, int y1, int cliph, int clipvh,
                                   Brush brushClip,
                                   VidkaProj proj,
                                   VidkaFileMapping projMapping,
                                   ProjectDimensions dimdim)
        {
            int x1    = dimdim.convert_Frame2ScreenX(curFrame);
            int x2    = dimdim.convert_Frame2ScreenX(curFrame + vclip.LengthFrameCalc);
            int clipw = x2 - x1;

            // active video clip deserves a special outline, fill white otherwise to hide gray background
            g.FillRectangle(brushClip, x1, y1, clipw, clipvh);
            DrawClipBitmaps(
                g: g,
                proj: proj,
                projMapping: projMapping,
                vclip: vclip,
                x1: x1,
                y1: y1,
                clipw: clipw,
                clipvh: clipvh,
                secStart: proj.FrameToSec(vclip.FrameStart),
                len: proj.FrameToSec(vclip.LengthFrameCalc));
            DrawWaveform(g, proj, projMapping, vclip, x1, y1 + clipvh, clipw, cliph - clipvh,
                         proj.FrameToSec(vclip.FrameStart), proj.FrameToSec(vclip.FrameEnd));
            if (vclip.IsMuted)
            {
                g.FillRectangle(brushHazyMute, x1, y1 + clipvh, x2 - x1, cliph - clipvh);
            }
            // waveform separator
            g.DrawLine(penGray, x1, y1 + clipvh, x2, y1 + clipvh);
            // outline rect
            g.DrawRectangle(penDefault, x1, y1, clipw, cliph);
            // still analyzing...
            if (vclip.IsNotYetAnalyzed)
            {
                g.DrawString("Still analyzing...", fontDefault, brushDefault, x1 + 5, y1 + 5);
            }
        }
コード例 #7
0
 public void SetParticulars(
     VidkaClipVideoAbstract vclip,
     MetaGeneratorInOtherThread metaGenerator,
     VidkaFileMapping fileMapping,
     VidkaProj proj)
 {
     this.vclip         = vclip;
     this.metaGenerator = metaGenerator;
     this.fileMapping   = fileMapping;
     this.proj          = proj;
     // ..... set up the vclip that we will draw
     vclipFullToDraw            = vclip.MakeCopy_VideoClip();
     vclipFullToDraw.FrameStart = 0;
     vclipFullToDraw.FrameEnd   = vclipFullToDraw.LengthFrameCalc;
     // ..... set up UI
     chkHasCustomAudio.Checked = vclip.HasCustomAudio;
     txtOffset.Text            = "" + vclip.CustomAudioOffset;
     //shitboxAlignVideoAudioControl.SetParticulars(vclip, fileMapping);
     SetFilenameLabel(vclip.CustomAudioFilename);
     updateAudioInfo(vclip);
     updateDisabilityOfControlBasedOnCheckbox();
 }
コード例 #8
0
 public void SetParticulars(
     VidkaClipVideoAbstract vclip,
     VidkaFileMapping fileMapping)
 {
     this.imageMan    = new ImageCacheManager();
     this.fileMapping = fileMapping;
     this.vclip       = vclip;
     // set up the vclip that we will draw
     vclipFullToDraw            = vclip.MakeCopy_VideoClip();
     vclipFullToDraw.FrameStart = 0;
     vclipFullToDraw.FrameEnd   = vclipFullToDraw.LengthFrameCalc;
     // set up the audio clip that we will draw
     aclipToDraw = new VidkaClipAudio()
     {
         FileName         = vclip.CustomAudioFilename,
         FileLengthSec    = vclip.CustomAudioLengthSec,
         FileLengthFrames = dimdim.SecToFrame(vclip.CustomAudioLengthSec ?? 0),
         FrameStart       = 0,
         FrameEnd         = dimdim.SecToFrame(vclip.CustomAudioLengthSec ?? 0),
     };
     imageMan.ImagesReady += imageMan_ImagesReady;
 }
コード例 #9
0
 public void SetFileMapping(VidkaFileMapping fileMapping)
 {
     this.fileMapping = fileMapping;
     Invalidate();
 }
コード例 #10
0
        internal void DrawCurrentClipVideo(
            Graphics g,
            VidkaClipVideo vclip,
            ProjectDimensions dimdim,
            VidkaProj proj,
            VidkaFileMapping projMapping,
            int w, int h,
            OutlineClipType type,
            bool isOriginalPlaybackMode,
            TrimDirection trimDirection,
            int trimBracketLength,
            long markerFrame,
            long selectedClipFrameOffset,
            long framesActiveMouseTrim)
        {
            int yMainTop   = dimdim.getY_main1(h);
            int xMain1     = dimdim.getScreenX1(vclip);
            int xMain2     = xMain1 + dimdim.convert_FrameToAbsX(vclip.LengthFrameCalc);    //hacky, I know
            int xMainDelta = dimdim.convert_FrameToAbsX(framesActiveMouseTrim);             //hacky, I know
            int xOrig1     = dimdim.convert_Frame2ScreenX_OriginalTimeline(vclip.FrameStart, vclip.FileLengthFrames, w);
            int xOrig2     = dimdim.convert_Frame2ScreenX_OriginalTimeline(vclip.FrameEnd, vclip.FileLengthFrames, w);
            int xOrigDelta = dimdim.convert_Frame2ScreenX_OriginalTimeline(framesActiveMouseTrim, vclip.FileLengthFrames, w);             // hacky, I know
            int y1         = dimdim.getY_original1(h);
            int y2         = dimdim.getY_original2(h);
            int yaudio     = dimdim.getY_original_half(h);

            // draw entire original clip (0 .. vclip.FileLength)
            g.FillRectangle(brushWhite, 0, y1, w, y2 - y1);
            g.FillRectangle(brushActive, xOrig1, y1, xOrig2 - xOrig1, y2 - y1);
            DrawClipBitmaps(g, proj, projMapping, vclip, 0, y1, w, yaudio - y1, 0, vclip.FileLengthSec ?? 0);
            DrawWaveform(g, proj, projMapping, vclip, 0, yaudio, w, y2 - yaudio, 0, vclip.FileLengthSec ?? 0);
            if (vclip.IsMuted)
            {
                g.FillRectangle(brushHazyMute, xOrig1, yaudio, xOrig2 - xOrig1, y2 - yaudio);
            }
            g.DrawLine(penGray, 0, yaudio, w, yaudio);
            g.DrawRectangle(penDefault, 0, y1, w, y2 - y1);

            //draw clip bounds
            g.DrawLine((type == OutlineClipType.Hover) ? penHover : penGray, xMain1, yMainTop, xOrig1, y2);
            g.DrawLine((type == OutlineClipType.Hover) ? penHover : penGray, xMain2, yMainTop, xOrig2, y2);
            g.DrawLine((type == OutlineClipType.Hover) ? penHover : penGray, xOrig1, y1, xOrig1, y2);
            g.DrawLine((type == OutlineClipType.Hover) ? penHover : penGray, xOrig2, y1, xOrig2, y2);
            if (type == OutlineClipType.Hover)
            {
                if (trimDirection == TrimDirection.Left)
                {
                    g.DrawLine(penActiveBoundary, xMain1 + xMainDelta, yMainTop, xOrig1 + xOrigDelta, y2);
                    drawTrimBracket(g, xOrig1, y1, y2, TrimDirection.Left, trimBracketLength, xOrigDelta, dimdim);
                }
                if (trimDirection == TrimDirection.Right)
                {
                    g.DrawLine(penActiveBoundary, xMain2 + xMainDelta, yMainTop, xOrig2 + xOrigDelta, y2);
                    drawTrimBracket(g, xOrig2, y1, y2, TrimDirection.Right, trimBracketLength, xOrigDelta, dimdim);
                }
            }

            // draw marker on
            var frameOffset = isOriginalPlaybackMode
                                ? markerFrame
                                : markerFrame - selectedClipFrameOffset + vclip.FrameStart;
            int xMarker = dimdim.convert_Frame2ScreenX_OriginalTimeline(frameOffset, vclip.FileLengthFrames, w);

            g.DrawLine(penMarker, xMarker, y1, xMarker, y2);
        }
コード例 #11
0
        public void DrawProjectVideoTimeline(
            Graphics g,
            int Width,
            int Height,
            VidkaProj proj,
            VidkaFileMapping projMapping,
            ProjectDimensions dimdim,
            VidkaClipVideo currentVideoClip,
            EditorDraggy draggy)
        {
            // draw video events
            long curFrame = 0;

            int y1     = dimdim.getY_main1(Height);
            int y2     = dimdim.getY_main2(Height);
            int yaudio = dimdim.getY_main_half(Height);
            int cliph  = y2 - y1;            // clip height (video and audio)
            int clipvh = yaudio - y1;        // clip (only video) height (just the video part, no audio!)
            int index  = 0;
            int draggyVideoShoveIndex = dimdim.GetVideoClipDraggyShoveIndex(draggy);

            foreach (var vclip in proj.ClipsVideo)
            {
                if (dimdim.isEvenOnTheScreen(curFrame, curFrame + vclip.LengthFrameCalc, Width))
                {
                    if (draggy.Mode == EditorDraggyMode.VideoTimeline && draggyVideoShoveIndex == index)
                    {
                        drawDraggyVideo(g, curFrame, y1, cliph, clipvh, draggy, dimdim);
                        curFrame += draggy.FrameLength;
                    }

                    if (draggy.VideoClip != vclip)
                    {
                        var brush = brushWhite;
                        if (vclip == currentVideoClip && vclip.IsLocked)
                        {
                            brush = brushLockedActiveClip;
                        }
                        else if (vclip == currentVideoClip)
                        {
                            brush = brushActive;
                        }
                        else if (vclip.IsLocked)
                        {
                            brush = brushLockedClip;
                        }
                        drawVideoClip(g, vclip,
                                      curFrame, y1, cliph, clipvh,
                                      brush,
                                      proj, projMapping, dimdim
                                      );
                    }
                }

                index++;
                if (draggy.VideoClip != vclip)
                {
                    curFrame += vclip.LengthFrameCalc;
                }
            }

            if (draggy.Mode == EditorDraggyMode.VideoTimeline && draggyVideoShoveIndex == index)
            {
                drawDraggyVideo(g, curFrame, y1, cliph, clipvh, draggy, dimdim);
            }
        }