LEADTOOLS Support
General
General Questions
Re: Wrong colors when creating a 8 bpp image when running as a service
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Wednesday, May 4, 2011 8:02:22 PM(UTC)
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?
#2
Posted
:
Thursday, May 5, 2011 6:47:17 AM(UTC)
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.
LEADTOOLS Support
General
General Questions
Re: Wrong colors when creating a 8 bpp image when running as a service
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.