Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, May 4, 2011 8:02:22 PM(UTC)
dumitrus

Groups: Registered
Posts: 1


Hi,

We are using a pdf library to convert the pages of a pdf document to images.

We are using RasterImage and RasterGraphics. The pdf library is drawing into the RasterGraphics.Graphics.

When creating the RasterImage we are passing the needed bits per pixel value (8) and a color palette (obtained from BitmapPalettes.Halftone256)

The simplified code is similar with this (ignore that the are some using blocks missing)

var bitmap = new RasterImage(RasterMemoryFlags.Conventional, page.Width, page.Height, 8, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, ltPalette, IntPtr.Zero, 0)

RasterGraphics graphics = RasterImagePainter.CreateGraphics(bitmap)
graphics.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.Graphics.ScaleTransform(scale, scale);
graphics.Graphics.Clear(Color.White);
page.Draw(graphics.Graphics);

var codecs = new RasterCodecs();
codecs.Save // to png or bitmap


The code is working fine while running as a console and generating the expected image. When running as a service the result is not as expected: there are some unexpected colors in the image (e.g. red - there is nothing red in the original pdf or the console generated image); also the quality of the image is a lot worse (e.g. smoothness).

What can be the problem?
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, May 5, 2011 6:47:17 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

This could be related to a limitation with Microsoft GDI+. The following page on Microsoft website states that "GDI+ functions and classes are not supported for use within a Windows service.":
http://msdn.microsoft.com/en-us/library/ms533798.aspx
If you must initiate the process form within a service you could look for a workaround such as putting the code in a regular console application and then make the service run this console EXE.
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.074 seconds.