zoukankan      html  css  js  c++  java
  • 漫画批量分割工具解决在MP4上看漫画

        前一段时间买了一个MP4,现在的电子产品真是便宜哪,5寸屏幕的MP4才400元真是实惠。MP4看电影真的是一级棒,但是看漫画问题就来了,小时候穷哪,没有钱买漫画书,多多少少有点漫画情节,现在的漫画大部分都是扫描的,图像格式大分辨率高,在我这个小小的MP4上看起来很吃力,特别是在看双拼漫画时更是吃力的很,这时候我就想到了能不能将双拼漫画搞成单拼的,再加上出血边,在5寸屏上看一定超级棒。

    所以动手开发了一上午,现在开放源程序给大家,有能力的兄弟们接着干吧。。哈哈哈。。有更新记得给我发一份。

    双拼漫画

    01_004

    转换之后的漫画

    aac93411-91af-4771-b429-1c902a96b632

     

     

    e3b3bd64-b90f-4758-8421-4b4319706070

    程序的开发界面:

    捕获

    捕获2

     

    核心代码:

       1: private List<string> fileList = new List<string>(200);
       2:         public ComicSplitMainForm()
       3:         {
       4:             InitializeComponent();
       5:         }
       6:  
       7:         private void toolStripButtonExit_Click(object sender, EventArgs e)
       8:         {
       9:             DialogResult returnValue = MessageBox.Show("您是否要退出?", "退出信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
      10:             if (returnValue == DialogResult.Yes)
      11:             {
      12:                 Application.Exit();
      13:             }
      14:         }
      15:  
      16:         private void toolStripButtonSet_Click(object sender, EventArgs e)
      17:         {
      18:             ComicSplitSetForm comicsplitSetForm = new ComicSplitSetForm();
      19:             DialogResult returnValue = comicsplitSetForm.ShowDialog();
      20:             if (returnValue == DialogResult.OK)
      21:             {
      22:                 this.toolStripButtonDir.Enabled = true;
      23:                 this.toolStripButtonFile.Enabled = true;
      24:                 this.toolStripButtonSplit.Enabled = true;
      25:                 this.toolStripButtonPrview.Enabled = true;
      26:             }
      27:         }
      28:  
      29:         private void toolStripButtonPrview_Click(object sender, EventArgs e)
      30:         {
      31:  
      32:         }
      33:  
      34:         private void toolStripButtonFile_Click(object sender, EventArgs e)
      35:         {
      36:             if (this.openFileDialogSelectFile.ShowDialog() == DialogResult.OK)
      37:             {
      38:                 this.listViewFile.Items.Clear();
      39:                 fileList.Clear();
      40:                 foreach (string tempFileName in this.openFileDialogSelectFile.FileNames)
      41:                 {
      42:                     fileList.Add(tempFileName);
      43:                     ListViewItem lv = new ListViewItem(Path.GetFileName(tempFileName));
      44:                     lv.SubItems.Add((new FileInfo(tempFileName).Length / 1024) + "KB");
      45:                     lv.SubItems.Add((new FileInfo(tempFileName).LastAccessTime).ToString());
      46:                     this.listViewFile.Items.Add(lv);
      47:                 }
      48:             }
      49:         }
      50:  
      51:         private void toolStripButtonDir_Click(object sender, EventArgs e)
      52:         {
      53:             if (this.folderBrowserDialogAddDir.ShowDialog() == DialogResult.OK)
      54:             {
      55:                 this.listViewFile.Items.Clear();
      56:                 fileList.Clear();
      57:                 foreach (string tempFileName in Directory.GetFiles(this.folderBrowserDialogAddDir.SelectedPath))
      58:                 {
      59:                     if (Path.GetExtension(tempFileName).Contains("png") || Path.GetExtension(tempFileName).Contains("jpg"))
      60:                     {
      61:                         fileList.Add(tempFileName);
      62:                         ListViewItem lv = new ListViewItem(Path.GetFileName(tempFileName));
      63:                         lv.SubItems.Add((new FileInfo(tempFileName).Length / 1024) + "KB");
      64:                         lv.SubItems.Add((new FileInfo(tempFileName).LastAccessTime).ToString());
      65:                         this.listViewFile.Items.Add(lv);
      66:                     }
      67:  
      68:                 }
      69:             }
      70:         }
      71:  
      72:         private void toolStripButtonSplit_Click(object sender, EventArgs e)
      73:         {
      74:             if (File.Exists(AppFrameWork.SaveDataName))
      75:             {
      76:                 string DirectoryName = AppFrameWork.AppDirName + Guid.NewGuid().ToString();
      77:                 Directory.CreateDirectory(DirectoryName);
      78:                 //反序列化读出配置文件
      79:                 ImageLib saveinfo;
      80:                 FileStream filestream = new FileStream(AppFrameWork.SaveDataName, FileMode.Open);
      81:                 BinaryFormatter bf = new BinaryFormatter();
      82:                 saveinfo = (ImageLib)bf.Deserialize(filestream);
      83:                 filestream.Close();
      84:                 int picNumCount = fileList.Count * 2;
      85:  
      86:                 ThreadDialogWithProcess threadDialogWithProcess = new ThreadDialogWithProcess();
      87:                 threadDialogWithProcess.Text = "生成图片中。。。";
      88:                 ThreadInfoClass threadInfoClass = new ThreadInfoClass();
      89:                 threadInfoClass.ShowForm = threadDialogWithProcess;
      90:                 threadInfoClass.Directoryname = DirectoryName;
      91:                 threadInfoClass.Saveinfo = saveinfo;
      92:                 threadInfoClass.PicNumCount = picNumCount;
      93:  
      94:                 threadDialogWithProcess.Text = "生成图片中。。。";
      95:                 ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(MakeBigPic), threadInfoClass);
      96:                 threadDialogWithProcess.ShowDialog();
      97:                 Process.Start(DirectoryName);
      98:  
      99:             }
     100:             else
     101:             {
     102:                 MessageBox.Show("请先进行设定!");
     103:             }
     104:         }
     105:         private void MakeBigPic(object status)
     106:         {
     107:             ThreadDialogWithProcess progressWindowForm = (ThreadDialogWithProcess)(status as ThreadInfoClass).ShowForm;
     108:             string DirectoryName = (status as ThreadInfoClass).Directoryname;
     109:             ImageLib saveinfo = (status as ThreadInfoClass).Saveinfo;
     110:             int picNumCount = (status as ThreadInfoClass).PicNumCount;
     111:             int picNum = 0;
     112:             try
     113:             {
     114:                 progressWindowForm.SetupThread(0, picNumCount);
     115:  
     116:                 foreach (string tempFile in fileList)
     117:                 {
     118:                     Image imgSamplePic = new Bitmap(tempFile);
     119:                     for (int i = 0; i < 2; i++)
     120:                     {
     121:  
     122:                         #region 数据显示
     123:                         progressWindowForm.SetDisplayText(String.Format("正在处理第{0}条/共{1}条", picNum, picNumCount));
     124:                         progressWindowForm.StepTo(picNum);
     125:                         if (progressWindowForm.IsAborting)
     126:                         {
     127:                             return;
     128:                         }
     129:                         if (progressWindowForm.IsAborting)
     130:                         {
     131:                             return;
     132:                         }
     133:                         #endregion
     134:  
     135:                         string strDestFile = string.Format(@"{0}\{1:D7}.jpg", DirectoryName, picNum);
     136:                         ImageTool.SplitImage(tempFile, strDestFile, saveinfo.DescRect[i], saveinfo.SrcRect[i]);
     137:                         picNum++;
     138:                     }
     139:                 }
     140:             }
     141:             catch (Exception exception)
     142:             {
     143:                 MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace);
     144:             }
     145:             finally
     146:             {
     147:                 if (progressWindowForm != null)
     148:                 {
     149:                     progressWindowForm.End();
     150:                 }
     151:             }
     152:         }
     153:  
     154:         private void toolStripButtonTurn90_Click(object sender, EventArgs e)
     155:         {
     156:             if (this.openFileDialogSelectFile.ShowDialog() == DialogResult.OK)
     157:             {
     158:                 fileList.Clear();
     159:                 foreach (string tempFilename in this.openFileDialogSelectFile.FileNames)
     160:                 {
     161:                     fileList.Add(tempFilename);
     162:                 }
     163:                 ThreadDialogWithProcess threadDialogWithProcess = new ThreadDialogWithProcess();
     164:                 threadDialogWithProcess.Text = "正在旋转图片";
     165:                 ThreadInfoClass threadInfoClass = new ThreadInfoClass();
     166:                 threadInfoClass.ShowForm = threadDialogWithProcess;
     167:  
     168:                 threadDialogWithProcess.Text = "正在旋转图片";
     169:                 ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(MakeRotate90Pic), threadInfoClass);
     170:                 threadDialogWithProcess.ShowDialog();
     171:             }
     172:         }
     173:         private void MakeRotate90Pic(object status)
     174:         {
     175:             ThreadDialogWithProcess progressWindowForm = (ThreadDialogWithProcess)(status as ThreadInfoClass).ShowForm;
     176:             try
     177:             {
     178:                 progressWindowForm.SetupThread(0, fileList.Count - 1);
     179:                 for (int i = 0; i < fileList.Count; ++i)
     180:                 {
     181:                     progressWindowForm.SetDisplayText(String.Format("正在处理第{0}条/共{1}条", i, fileList.Count));
     182:                     progressWindowForm.StepTo(i);
     183:  
     184:                     //获得图片
     185:                     Image img = KiRotate90(new Bitmap(fileList[i]));
     186:                     Graphics g = Graphics.FromImage(img);
     187:                     // 绘图平滑程序
     188:                     g.SmoothingMode = SmoothingMode.HighQuality;
     189:  
     190:                     // 图片输出质量
     191:                     g.CompositingQuality = CompositingQuality.HighQuality;
     192:                     g.Dispose();
     193:                     img.Save(fileList[i], ImageFormat.Jpeg);
     194:  
     195:  
     196:                     if (progressWindowForm.IsAborting)
     197:                     {
     198:                         return;
     199:                     }
     200:                     if (progressWindowForm.IsAborting)
     201:                     {
     202:                         return;
     203:                     }
     204:                 }
     205:             }
     206:             catch (Exception exception)
     207:             {
     208:                 MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace);
     209:             }
     210:             finally
     211:             {
     212:                 if (progressWindowForm != null)
     213:                 {
     214:                     progressWindowForm.End();
     215:                 }
     216:             }
     217:  
     218:  
     219:  
     220:         }
     221:         public static Bitmap KiRotate90(Bitmap img)
     222:         {
     223:             //顺时针旋转90度     RotateFlipType.Rotate90FlipNone
     224:             //逆时针旋转90度     RotateFlipType.Rotate270FlipNone
     225:             //水平翻转    RotateFlipType.Rotate180FlipY
     226:             //垂直翻转    RotateFlipType.Rotate180FlipX
     227:             try
     228:             {
     229:                 img.RotateFlip(RotateFlipType.Rotate90FlipNone);
     230:                 return img;
     231:             }
     232:             catch
     233:             {
     234:                 return null;
     235:             }
     236:         }
     237:     }

    源程序下载地址:

    http://www.box.net/shared/hxkr3vgg3l

  • 相关阅读:
    Sql例子Sp_ExecuteSql 带参数
    Flex显示麦克风当前音量
    无法将 flash.display::Sprite@156b7b1 转换为 mx.core.IUIComponent
    FMS (端口问题)如何穿透防火墙
    19:A*B问题
    6264:走出迷宫
    2753:走迷宫
    1792:迷宫
    换钱问题(经典枚举样例)
    1943(2.1)
  • 原文地址:https://www.cnblogs.com/chu888chu888/p/1749909.html
Copyright © 2011-2022 走看看