@@ -23,88 +23,125 @@ Public Class GameEditor
2323
2424 Private Sub SaveButton_Click(sender As Object , e As RoutedEventArgs) Handles SaveButton.Click
2525 If Not String .IsNullOrEmpty(ProjectDirectory) Then
26+
27+ Dim Quantizer As New WuQuantizer()
28+
29+ 'Create the res\image directory
2630 If Not Directory.Exists(ProjectDirectory + "\res\image" ) Then
2731 Directory.CreateDirectory(ProjectDirectory + "\res\image" )
2832 End If
2933
30- Dim Quantizer As New WuQuantizer()
31-
3234 'Save selected XMB cover as compressed PNG
3335 If CoverPictureBox.Tag IsNot Nothing AndAlso Not File.Exists(ProjectDirectory + "\res\jkt_001.png" ) Then
34- Dim Cover1Bitmap As Bitmap = Utils.GetResizedBitmap(CoverPictureBox.Tag.ToString(), 140 , 200 )
35- Dim Cover2Bitmap As Bitmap = Utils.GetResizedBitmap(CoverPictureBox.Tag.ToString(), 74 , 108 )
36-
37- If Cover1Bitmap.PixelFormat <> Imaging.PixelFormat.Format32bppArgb Then
38- Utils.ConvertTo32bppAndDisposeOriginal(Cover1Bitmap)
39- End If
40- If Cover2Bitmap.PixelFormat <> Imaging.PixelFormat.Format32bppArgb Then
41- Utils.ConvertTo32bppAndDisposeOriginal(Cover2Bitmap)
36+ If TypeOf CoverPictureBox.Tag Is String Then
37+ Dim Cover1Bitmap As Bitmap = Utils.GetResizedBitmap(CoverPictureBox.Tag.ToString(), 140 , 200 )
38+ Dim Cover2Bitmap As Bitmap = Utils.GetResizedBitmap(CoverPictureBox.Tag.ToString(), 74 , 108 )
39+
40+ If Cover1Bitmap IsNot Nothing AndAlso Cover2Bitmap IsNot Nothing Then
41+ If Cover1Bitmap.PixelFormat <> Imaging.PixelFormat.Format32bppArgb Then
42+ Utils.ConvertTo32bppAndDisposeOriginal(Cover1Bitmap)
43+ End If
44+ If Cover2Bitmap.PixelFormat <> Imaging.PixelFormat.Format32bppArgb Then
45+ Utils.ConvertTo32bppAndDisposeOriginal(Cover2Bitmap)
46+ End If
47+
48+ Try
49+ Using CompressedImage = Quantizer.QuantizeImage(Cover1Bitmap)
50+ CompressedImage?.Save(ProjectDirectory + "\res\jkt_001.png" , Imaging.ImageFormat.Png)
51+ End Using
52+ Using CompressedImage = Quantizer.QuantizeImage(Cover2Bitmap)
53+ CompressedImage?.Save(ProjectDirectory + "\res\jkt_002.png" , Imaging.ImageFormat.Png)
54+ End Using
55+ Catch ex As Exception
56+ MsgBox( "Could not resize the selected cover. Please save it manually in the project folder:" + vbCrLf +
57+ """\res\jkt_001.png"" 140 x 200" + vbCrLf +
58+ """\res\jkt_002.png"" 74 x 108" , MsgBoxStyle.Exclamation, "Cover Warning" )
59+ Finally
60+ Cover1Bitmap.Dispose()
61+ Cover2Bitmap.Dispose()
62+ End Try
63+ Else
64+ MsgBox( "Could not resize the selected cover. Please save it manually in the project folder:" + vbCrLf +
65+ """\res\jkt_001.png"" 140 x 200" + vbCrLf +
66+ """\res\jkt_002.png"" 74 x 108" , MsgBoxStyle.Exclamation, "Cover Warning" )
67+ End If
4268 End If
43-
44- Try
45- Using CompressedImage = Quantizer.QuantizeImage(Cover1Bitmap)
46- CompressedImage.Save(ProjectDirectory + "\res\jkt_001.png" , Imaging.ImageFormat.Png)
47- End Using
48- Using CompressedImage = Quantizer.QuantizeImage(Cover2Bitmap)
49- CompressedImage.Save(ProjectDirectory + "\res\jkt_002.png" , Imaging.ImageFormat.Png)
50- End Using
51- Catch ex As Exception
52- MsgBox( "Could not compress PNG." + vbCrLf + ex.Message, MsgBoxStyle.Exclamation)
53- Finally
54- Cover1Bitmap.Dispose()
55- Cover2Bitmap.Dispose()
56- End Try
5769 End If
5870
71+ 'Background image
5972 If BackgroundImagePictureBox.Tag IsNot Nothing AndAlso Not File.Exists(ProjectDirectory + "\res\image\0.png" ) Then
60- Dim BackgroundImageBitmap As Bitmap = Utils.GetResizedBitmap(BackgroundImagePictureBox.Tag.ToString, 640 , 350 )
61- If BackgroundImageBitmap.PixelFormat <> Imaging.PixelFormat.Format32bppArgb Then
62- Utils.ConvertTo32bppAndDisposeOriginal(BackgroundImageBitmap)
73+ If TypeOf BackgroundImagePictureBox.Tag Is String Then
74+ Dim BackgroundImageBitmap As Bitmap = Utils.GetResizedBitmap(BackgroundImagePictureBox.Tag.ToString, 640 , 350 )
75+ If BackgroundImageBitmap IsNot Nothing Then
76+ If BackgroundImageBitmap.PixelFormat <> Imaging.PixelFormat.Format32bppArgb Then
77+ Utils.ConvertTo32bppAndDisposeOriginal(BackgroundImageBitmap)
78+ End If
79+
80+ Try
81+ Using CompressedImage = Quantizer.QuantizeImage(BackgroundImageBitmap)
82+ CompressedImage?.Save(ProjectDirectory + "\res\image\0.png" , Imaging.ImageFormat.Png)
83+ End Using
84+ Catch ex As Exception
85+ MsgBox( "Could not resize the selected background. Please save it manually in the project folder:" + vbCrLf +
86+ """\res\image\0.png"" 640 x 350" , MsgBoxStyle.Exclamation, "Background Warning" )
87+ Finally
88+ BackgroundImageBitmap.Dispose()
89+ End Try
90+ Else
91+ MsgBox( "Could not resize the selected background. Please save it manually in the project folder:" + vbCrLf +
92+ """\res\image\0.png"" 640 x 350" , MsgBoxStyle.Exclamation, "Background Warning" )
93+ End If
6394 End If
64-
65- Try
66- Using CompressedImage = Quantizer.QuantizeImage(BackgroundImageBitmap)
67- CompressedImage.Save(ProjectDirectory + "\res\image\0.png" , Imaging.ImageFormat.Png)
68- End Using
69- Catch ex As Exception
70- MsgBox( "Could not compress PNG." + vbCrLf + ex.Message, MsgBoxStyle.Exclamation)
71- Finally
72- BackgroundImageBitmap.Dispose()
73- End Try
7495 End If
7596
97+ 'Screenshots
7698 If ScreenshotImage1PictureBox.Tag IsNot Nothing AndAlso Not File.Exists(ProjectDirectory + "\res\image\1.png" ) Then
77- Dim ScreenshotImageBitmap As Bitmap = Utils.GetResizedBitmap(ScreenshotImage1PictureBox.Tag.ToString, 640 , 350 )
78- If ScreenshotImageBitmap.PixelFormat <> Imaging.PixelFormat.Format32bppArgb Then
79- Utils.ConvertTo32bppAndDisposeOriginal(ScreenshotImageBitmap)
99+ If TypeOf ScreenshotImage1PictureBox.Tag Is String Then
100+ Dim ScreenshotImageBitmap As Bitmap = Utils.GetResizedBitmap(ScreenshotImage1PictureBox.Tag.ToString, 640 , 350 )
101+ If ScreenshotImageBitmap IsNot Nothing Then
102+ If ScreenshotImageBitmap.PixelFormat <> Imaging.PixelFormat.Format32bppArgb Then
103+ Utils.ConvertTo32bppAndDisposeOriginal(ScreenshotImageBitmap)
104+ End If
105+
106+ Try
107+ Using CompressedImage = Quantizer.QuantizeImage(ScreenshotImageBitmap)
108+ CompressedImage?.Save(ProjectDirectory + "\res\image\1.png" , Imaging.ImageFormat.Png)
109+ End Using
110+ Catch ex As Exception
111+ MsgBox( "Could not resize the selected screenshot 1. Please save it manually in the project folder:" + vbCrLf +
112+ """\res\image\1.png"" 640 x 350" , MsgBoxStyle.Exclamation, "Screenshot 1 Warning" )
113+ Finally
114+ ScreenshotImageBitmap.Dispose()
115+ End Try
116+ Else
117+ MsgBox( "Could not resize the selected screenshot 1. Please save it manually in the project folder:" + vbCrLf +
118+ """\res\image\1.png"" 640 x 350" , MsgBoxStyle.Exclamation, "Screenshot 1 Warning" )
119+ End If
80120 End If
81-
82- Try
83- Using CompressedImage = Quantizer.QuantizeImage(ScreenshotImageBitmap)
84- CompressedImage.Save(ProjectDirectory + "\res\image\1.png" , Imaging.ImageFormat.Png)
85- End Using
86- Catch ex As Exception
87- MsgBox( "Could not compress PNG." + vbCrLf + ex.Message, MsgBoxStyle.Exclamation)
88- Finally
89- ScreenshotImageBitmap.Dispose()
90- End Try
91121 End If
92122 If ScreenshotImage2PictureBox.Tag IsNot Nothing AndAlso Not File.Exists(ProjectDirectory + "\res\image\2.png" ) Then
93- Dim ScreenshotImageBitmap As Bitmap = Utils.GetResizedBitmap(ScreenshotImage2PictureBox.Tag.ToString, 640 , 350 )
94-
95- If ScreenshotImageBitmap.PixelFormat <> Imaging.PixelFormat.Format32bppArgb Then
96- Utils.ConvertTo32bppAndDisposeOriginal(ScreenshotImageBitmap)
123+ If TypeOf ScreenshotImage2PictureBox.Tag Is String Then
124+ Dim ScreenshotImageBitmap As Bitmap = Utils.GetResizedBitmap(ScreenshotImage2PictureBox.Tag.ToString, 640 , 350 )
125+ If ScreenshotImageBitmap IsNot Nothing Then
126+ If ScreenshotImageBitmap.PixelFormat <> Imaging.PixelFormat.Format32bppArgb Then
127+ Utils.ConvertTo32bppAndDisposeOriginal(ScreenshotImageBitmap)
128+ End If
129+
130+ Try
131+ Using CompressedImage = Quantizer.QuantizeImage(ScreenshotImageBitmap)
132+ CompressedImage?.Save(ProjectDirectory + "\res\image\2.png" , Imaging.ImageFormat.Png)
133+ End Using
134+ Catch ex As Exception
135+ MsgBox( "Could not resize the selected screenshot 2. Please save it manually in the project folder:" + vbCrLf +
136+ """\res\image\2.png"" 640 x 350" , MsgBoxStyle.Exclamation, "Screenshot 2 Warning" )
137+ Finally
138+ ScreenshotImageBitmap.Dispose()
139+ End Try
140+ Else
141+ MsgBox( "Could not resize the selected screenshot 2. Please save it manually in the project folder:" + vbCrLf +
142+ """\res\image\2.png"" 640 x 350" , MsgBoxStyle.Exclamation, "Screenshot 2 Warning" )
143+ End If
97144 End If
98-
99- Try
100- Using CompressedImage = Quantizer.QuantizeImage(ScreenshotImageBitmap)
101- CompressedImage.Save(ProjectDirectory + "\res\image\2.png" , Imaging.ImageFormat.Png)
102- End Using
103- Catch ex As Exception
104- MsgBox( "Could not compress PNG." + vbCrLf + ex.Message, MsgBoxStyle.Exclamation)
105- Finally
106- ScreenshotImageBitmap.Dispose()
107- End Try
108145 End If
109146
110147 'Write info.sys to res directory
0 commit comments