• R/O
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

圧縮フォルダを解凍する。画像が複数含まれるので分割する。フォルダごとにpdfに変換


Commit MetaInfo

修訂4 (tree)
時間2017-09-10 11:17:48
作者bellyoshi

Log Message

Change Summary

差異

--- WindowsApp1/WindowsApp1/Form1.vb (revision 3)
+++ WindowsApp1/WindowsApp1/Form1.vb (revision 4)
@@ -3,6 +3,7 @@
33 Imports iTextSharp.text
44 Imports WindowsApp1
55
6+
67 Public Class Form1
78
89 Private Class Form1Logger
@@ -40,24 +41,46 @@
4041 End Using
4142 End Using
4243 End Sub
44+ Dim filename_count = 1
45+ Private Sub SaveTo(ByVal image As Bitmap, ByVal temppath As String)
46+ Dim filepath = Path.Combine(temppath, String.Format("{0:D4}.jpg", filename_count))
47+ image.Save(filepath, Imaging.ImageFormat.Jpeg)
48+ End Sub
4349
4450
45-
4651 Private Sub zipToPdf(zipFilePath As String, srcFiles As AppTempDir, tempFiles As AppTempDir)
4752
4853 '解凍処理
4954 System.IO.Compression.ZipFile.ExtractToDirectory(zipFilePath, srcFiles.Path)
5055
51- Dim filename_count = 0
56+ filename_count = 1
5257 'tempフォルダのjpegファイルを列挙し以下を繰り返す
5358 Dim files As String() = System.IO.Directory.GetFiles(srcFiles.Path, "*.jpg", System.IO.SearchOption.AllDirectories)
5459 For Each filepath As String In files
5560 Dim filename = System.IO.Path.GetFileName(filepath)
56- '先頭ファイルはそのままとする。001.jpeg
61+ '先頭ファイルはそのままとする。001.jpg
5762 If filename.Contains("001") Then
58- Dim destfilepath = Path.Combine(tempFiles.Path, filename)
59- File.Copy(filepath, destfilepath)
63+ Dim image As New Bitmap(filepath)
64+ SaveTo(image, tempFiles.Path)
65+ '左側画像を保存する。
66+ Else
67+ Dim image As New Bitmap(filepath)
68+ Dim width As Integer = image.Width / 2
69+ Dim height As Integer = image.Height
70+ Dim desRect As New Drawing.Rectangle(0, 0, width, height)
71+ Dim destImage As New Bitmap(width, height)
72+ Dim g = Graphics.FromImage(destImage)
73+ '右側画像を保存する。
74+ Dim srcRect As New Drawing.Rectangle(width, 0, width, height)
75+ g.DrawImage(image, desRect, srcRect, GraphicsUnit.Pixel)
76+ SaveTo(destImage, tempFiles.Path)
77+ '左側画像を保存する。
78+ filename_count += 1
79+ Dim srcRect2 As New Drawing.Rectangle(0, 0, width, height)
80+ g.DrawImage(image, desRect, srcRect2, GraphicsUnit.Pixel)
81+ SaveTo(destImage, tempFiles.Path)
6082 End If
83+ filename_count += 1
6184 Next
6285 '2番目以降のファイルを読み込む。
6386 '2つに分割し右側をfilename_count.jpeg,左側をfilename_count+1.jpegとして保存する