2626using System . Collections . Generic ;
2727using System . Drawing ;
2828using System . Drawing . Imaging ;
29+ using System . IO ;
30+ using System . Linq ;
2931using System . Text ;
3032using System . Threading ;
3133using System . Windows . Forms ;
3234using PdfConstruct . DataObjects ;
35+ using PdfConstruct . Properties ;
3336using PdfSharp . Pdf ;
3437using PdfSharp . Drawing ;
38+ using PdfSharp . Pdf . Advanced ;
3539using Support . IO ;
3640using Support . UI ;
3741
@@ -237,8 +241,10 @@ private void listViewCards_KeyDown(object sender, KeyEventArgs e)
237241 private void ExportThread ( object zParam )
238242 {
239243 var zDocument = new PdfDocument ( ) ;
244+ zDocument . Options . ColorMode = PdfColorMode . Undefined ;
245+ //zDocument.Options.NoCompression = true;
240246
241- List < string > listFiles = ( List < string > ) zParam ;
247+ var listFiles = ( List < string > ) zParam ;
242248 Func < decimal > funcGetDpi = ( ) => numericDPI . Value ;
243249 Func < string > funcGetOutputPath = ( ) => txtOutputPath . Text ;
244250
@@ -249,26 +255,28 @@ private void ExportThread(object zParam)
249255 {
250256 var zImgSrc = Image . FromFile ( sFile ) ;
251257
252- #if false
258+ // wipe out any transparency on the images
253259 var zImgDestination = new Bitmap ( zImgSrc . Width , zImgSrc . Height , PixelFormat . Format24bppRgb ) ;
254260 var zImageGfx = Graphics . FromImage ( zImgDestination ) ;
255261 zImageGfx . Clear ( Color . White ) ;
256262 zImageGfx . DrawImage ( zImgSrc , 0 , 0 ) ;
257- zImgSrc . Dispose ( ) ;
258- zImgDestination . Save ( "C:\\ tmp.bmp" , ImageFormat . Bmp ) ;
259- zImgDestination . Dispose ( ) ;
260- zImgSrc = Image . FromFile ( "C:\\ tmp.bmp" ) ;
261- #endif
263+
262264 var zPage = zDocument . AddPage ( new PdfPage ( )
263265 {
264266 Width = XUnit . FromInch ( ( double ) zImgSrc . Width / dDPI ) ,
265267 Height = XUnit . FromInch ( ( double ) zImgSrc . Height / dDPI )
266268 } ) ;
267269 var zGfx = XGraphics . FromPdfPage ( zPage ) ;
268- var zXImage = XImage . FromGdiPlusImage ( zImgSrc ) ;
269- zGfx . DrawImage ( zXImage , Point . Empty ) ;
270- progressBar . InvokeAction ( ( ) => progressBar . Value ++ ) ;
270+ using ( var zMem = new MemoryStream ( ) )
271+ {
272+ zImgDestination . Save ( zMem , ImageFormat . Bmp ) ;
273+ var zXImage = XImage . FromStream ( zMem ) ;
274+ zGfx . DrawImage ( zXImage , new XPoint ( ) ) ;
275+ zXImage . Dispose ( ) ;
276+ }
277+ zImgDestination . Dispose ( ) ;
271278 zImgSrc . Dispose ( ) ;
279+ progressBar . InvokeAction ( ( ) => progressBar . Value ++ ) ;
272280 } ) ;
273281 zDocument . Save ( sOutputPth ) ;
274282 ConfigureControlState ( false ) ;
0 commit comments