public void Next() { if (F.SelectedPanel.ind + 1 < F.panel1.Controls.Count) { F.SuspendLayout(); ComicPanel B = (ComicPanel)F.panel1.Controls[F.SelectedPanel.ind + 1]; F.SelectedPanel.Unselect(); /*try * { * F.panel1.VerticalScroll.Value += B.Height; * } * catch * { * F.panel1.VerticalScroll.Value = F.panel1.VerticalScroll.Minimum; * }*/ //F.panel1.VerticalScroll.Value += B.Height; B.Select(); F.ResumeLayout(); } else { if (F.panel1.Controls.Count > 0) { F.SuspendLayout(); ComicPanel B = (ComicPanel)F.panel1.Controls[0]; F.SelectedPanel.Unselect(); //F.panel1.VerticalScroll.Value = F.panel1.VerticalScroll.Minimum; B.Select(); if (Playing) { LoopAudio(); } last = DateTime.Now; F.ResumeLayout(); } else { return; } } if (F.SelectedPanel != null) { stop = true; slfps = 1000f / F.SelectedPanel.delay; textBox3.Text = "" + slfps; textBox4.Text = "" + F.SelectedPanel.delay; stop = false; } }
public void Prev() { if (F.SelectedPanel.ind - 1 >= 0) { ComicPanel B = (ComicPanel)F.panel1.Controls[F.SelectedPanel.ind - 1]; F.SelectedPanel.Unselect(); /*try * { * F.panel1.VerticalScroll.Value -= B.Height; * } * catch * { * F.panel1.VerticalScroll.Value = F.panel1.VerticalScroll.Maximum; * }*/ B.Select(); } else { if (F.panel1.Controls.Count > 0) { ComicPanel B = (ComicPanel)F.panel1.Controls[F.panel1.Controls.Count - 1]; F.SelectedPanel.Unselect(); /*try * { * F.panel1.VerticalScroll.Value = F.panel1.VerticalScroll.Maximum; * } * catch * { * }*/ B.Select(); } else { return; } } if (F.SelectedPanel != null) { stop = true; slfps = 1000f / F.SelectedPanel.delay; textBox3.Text = "" + slfps; textBox4.Text = "" + F.SelectedPanel.delay; stop = false; } }
public int GetFramedelay() { int cd = ddel; int i = 0; while (i < F.panel1.Controls.Count) { ComicPanel CP = (ComicPanel)F.panel1.Controls[i]; if (CP.delay > 0 && CP.delay < cd) { cd = CP.delay; } i++; } return(cd); //return (int)(1000f / cd); }
public void SaveGimpLayers() { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { int delay = ddel; int i = 0; while (i < F.panel1.Controls.Count) { ComicPanel CP = (ComicPanel)F.panel1.Controls[i]; if (CP.delay > 0) { delay = CP.delay; } Bitmap B = F.img[i]; B.Save(folderBrowserDialog1.SelectedPath + "/frame" + ("" + i).PadLeft(5, '0') + "(" + delay + " ms)" + ".png"); i++; } } }
public int GetDelayTo(int frame) { int delay = 0; int i = 0; int cd = ddel; int count = F.img.Count; while (i < (frame - 1) && i < count) { ComicPanel B = (ComicPanel)F.panel1.Controls[i]; cd = B.delay; if (cd < 1) { cd = ddel; } delay += cd; i++; } return(delay); }
private void button7_Click(object sender, EventArgs e) { CD = 0; del = 0; timer1_Tick(null, null); ComicPanel B = (ComicPanel)F.panel1.Controls[0]; F.SelectedPanel.Unselect(); /*try * { * F.panel1.VerticalScroll.Value = 0; * } * catch * { * }*/ B.Select(); last = DateTime.Now; timer1_Tick(null, null); }
private void timer1_Tick(object sender, EventArgs e) { if (Playing) { updatetimer(); } if (F.SelectedPanel != null) { } fixframe(); /*if (lastframe != F.SelectedPanel && F.SelectedPanel != null) * { * if (pictureBox1.Image != null) * { * pictureBox1.Image.Dispose(); * } * Bitmap B = F.img[F.SelectedPanel.ind]; * pictureBox1.Image = F.Crop(B); * if (pictureBox1.Image == B) * { * pictureBox1.Image = new Bitmap(B); * } * pictureBox1.Invalidate(); * stop = true; * slfps = 1000f / F.SelectedPanel.delay; * textBox3.Text = "" + slfps; * textBox4.Text = "" + F.SelectedPanel.delay; * stop = false; * lastframe = F.SelectedPanel; * }*/ if ((!Playing || ddel < 1) && forcetime == 0) { //lastbmp = F.SelBMP; return; } if (F.SelectedPanel == null) { if (F.panel1.Controls.Count > 0) { F.panel1.Controls[0].Focus(); } return; } if (lastframe == null) { lastframe = F.SelectedPanel; stop = true; slfps = 1000f / F.SelectedPanel.delay; textBox3.Text = "" + slfps; textBox4.Text = "" + F.SelectedPanel.delay; stop = false; } //del+=10; if (Playing) { del += DateTime.Now.Subtract(last).TotalMilliseconds; } else { del += forcetime; } last = DateTime.Now; int MD = F.SelectedPanel.delay; MD = CurrentDelay; if (MD == 0) { MD = ddel; } label7.Text = "Frame" + F.SelectedPanel.ind + " Delay:" + MD; //label7.Text = "Current Delay:" + MD; if (Playing) { //timer1.Interval = Math.Max(MD / 2,10); timer1.Interval = 10; } bool ok = false; bool started = false; bool frameskip = true; while (del >= MD && MD > 0 && (!started || frameskip)) { //del -=ddel; del -= MD; ok = true; Next(); //MD = F.SelBMP.delay; if (F.SelectedPanel.delay > 0) { MD = F.SelectedPanel.delay; } //MD = CurrentDelay; ////MD = F.SelectedPanel.delay; /*if (MD == 0) * { * MD = ddel; * }*/ started = true; /*if (F.SelectedPanel.delay > 0) * { * MD = F.SelectedPanel.delay; * }*/ //pictureBox1.Image = F.img[F.SelBMP.ind]; } if (ok /* && forcetime<1*/ && false) { int ft = forcetime; forcetime = 0; timer1_Tick(null, null); forcetime = ft; if (ft < 1) { pictureBox1.Invalidate(); } /*if (Playing) * { * timer1.Interval = Math.Max(MD / 4,10); * }*/ //fixframe(); } //pictureBox1.Invalidate(); //lastbmp = F.SelBMP; }
private void fixframe(bool force = false) { if (force || (lastframe != F.SelectedPanel && F.SelectedPanel != null)) { /*if (pictureBox1.Image != null) * { * pictureBox1.Image.Dispose(); * }*/ /*if (pictureBox1.Image != null && !F.img.Contains((Bitmap)pictureBox1.Image)) * { * pictureBox1.Image.Dispose(); * }*/ Bitmap B = F.img[F.SelectedPanel.ind]; if (F.Cropper.IWidth != 100 || F.Cropper.IHeight != 100) { //pictureBox1.Image = F.Crop(B); B = F.Crop(B); } else { //pictureBox1.Image = B; } if (pictureBox1.Image == B) { //pictureBox1.Image = new Bitmap(B); } if (buffer == null || !buffer.Size.Equals(panel3.Size)) { if (buffer != null) { bufferG.Dispose(); buffer.Dispose(); } buffer = new Bitmap(panel3.Width, panel3.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); bufferG = Graphics.FromImage(buffer); bufferG.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed; bufferG.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; bufferG.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; //the default InterpolationMode is very very slow. //less slow //bufferG.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear; //fastest bufferG.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; //Text = "RND:" + new Random().Next(); } Bitmap R = buffer; Graphics G = bufferG; /*Bitmap R = new Bitmap(pictureBox1.Width, pictureBox1.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); * Graphics G = Graphics.FromImage(R);*/ G.DrawImage(B, 0, 0, R.Width, R.Height); //G.Dispose(); //panelG.Clear(Color.Red); //panelG.DrawImage(buffer, 0, 0); pictureBox1.Image = R; //pictureBox1.Invalidate(); stop = true; slfps = 1000f / F.SelectedPanel.delay; textBox3.Text = "" + slfps; textBox4.Text = "" + F.SelectedPanel.delay; stop = false; lastframe = F.SelectedPanel; } }
public void ExportSequence(string directory, int framedelay, bool resize = false) { if (Playing) { /*Playing = false; * textBox3.Enabled = true; * textBox4.Enabled = true; * pictureBox1.Focus();*/ StopPlayback(); } /*if (thetimer != null) * { * thetimer.Dispose(); * thetimer = null; * }*/ timer1.Stop(); bool started = false; //int fps = (int)float.Parse(S.textBox1.Text); int fps = framedelay; forcetime = fps; CD = 0; ComicPanel CP = (ComicPanel)F.panel1.Controls[0]; F.SelectedPanel.Unselect(); /*try * { * F.panel1.VerticalScroll.Value = 0; * } * catch * { * }*/ CP.Select(); int frame = 0; int lastpanel = -1; MemoryStream MS = null; ProgressWindow PW = new ProgressWindow(); PW.Show(); ProgressBar PB = PW.progressBar1; PB.Maximum = F.panel1.Controls.Count; PB.Step = 1; PW.Text = "Exporting sequence... Framerate:" + (int)(1000f / fps); Size first = Size.Empty; //PW.label1.Text = "Exporting your frame sequence please wait..."; while (!started /* || CurrentDelay!=0*/ || F.SelectedPanel.ind != 0) { //started = true; timer1_Tick(null, null); if (!started || F.SelectedPanel.ind != 0) { if (F.SelectedPanel.ind != 0) { started = true; } if (F.SelectedPanel.ind != lastpanel) { Bitmap TB = F.img[F.SelectedPanel.ind]; int W = TB.Width - (TB.Width & 1); int H = TB.Height - (TB.Height & 1); Bitmap B = TB; bool clone = false; if (first.IsEmpty) { first.Width = W; first.Height = H; } else if (resize) { W = first.Width; H = first.Height; } if (B.Width != W || B.Height != H) { //B = TB.Clone(new Rectangle(0, 0, W, H), System.Drawing.Imaging.PixelFormat.Format24bppRgb); Size s = new Size(W, H); Bitmap ret = new Bitmap(s.Width, s.Height); Graphics G = Graphics.FromImage(ret); Point P = Point.Empty; //Point P = new Point((int)(B.Size.Width * (IX * 0.01)), (int)(B.Size.Height * (IY * 0.01))); //Size Sz = new Size((int)(B.Size.Width * (IWidth * 0.01)), (int)(B.Size.Height * (IHeight * 0.01))); Size Sz = s; G.DrawImage(B, new Rectangle(Point.Empty, ret.Size), new Rectangle(P, Sz), GraphicsUnit.Pixel); G.Dispose(); B = ret; //return ret; clone = true; } Bitmap temp = B; if (F.Cropper.IWidth != 100 && F.Cropper.IHeight != 100) { B = F.Crop(B); } if (temp != B && temp != TB) { temp.Dispose(); } temp = B; B = F.GetStretch(B); if (temp != B && temp != TB) { temp.Dispose(); } temp = null; //B = F.GetStretch(F.Crop(B)); clone = true; //B.Save(directory + "/frame" + ("" + frame).PadLeft(5, '0') + ".png"); if (MS != null) { MS.Dispose(); } MS = new MemoryStream(); B.Save(MS, System.Drawing.Imaging.ImageFormat.Png); if (clone && B != TB) { B.Dispose(); } B = null; PB.PerformStep(); PW.Invalidate(); GC.Collect(); } using (var fileStream = File.Create(directory + "/frame" + ("" + frame).PadLeft(5, '0') + ".png")) { MS.Seek(0, SeekOrigin.Begin); MS.CopyTo(fileStream); } frame++; } } PW.Close(); PW.Dispose(); forcetime = 0; timer1.Start(); //thetimer = new System.Threading.Timer((a) => { pictureBox1.Invalidate(); }, null, 0, 10); }