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 : Monday, February 18, 2008 1:56:20 AM(UTC)
alwayssmiling

Groups: Registered
Posts: 27


I'm using rasterimaging pro v15.0. And the development environment is dotnet c# and VS 2005.

We have two images in our application one is tiff and from this i'm creating a jpeg image using the following code.

RasterCodecs codecs = new RasterCodecs();

codecs.Save(TiffImage, imagePath, RasterImageFormat.Jpeg, 8); //saves the jpeg

m_JpegImage = codecs.Load(imagePath);
codecs.Dispose();


after creating and loading, the image's bits per pixel is 8. After that, using createGdiPlusGraphics() i'm drawing some shapes on the image. At this time the bitsperpixel value is becoming 24. After that to apply some colors on the image i'm acessing getpalette() method of the image. For the first image its returning the proper value. But for the second jpeg image it's returning null. Is it due to drawing do i need to set any other properties to get the palette from the image.

Please let me know what is 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 : Monday, February 18, 2008 6:25:21 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

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




Hello,
About the conversion
from 8 to 24 bits, this is a Windows limitation when you create a GDI+ device context.




About the
palette returning as null, if you do that for the image after it was converted
to 24 bits, this is normal. Only images that are 8 bits or less have palettes in LEADTOOLS.

 
#3 Posted : Monday, February 18, 2008 7:04:20 PM(UTC)
alwayssmiling

Groups: Registered
Posts: 27


Thank you for the reply. Can i convert back this 24 bit image into 8 bit image. Any methods are avaialable in leadtools to achieve this.

Here i'm using palettes to apply some colors on the image. Can i perform the same thing using any other properties and methods. If there are any please let me know. Initially when i created the image its 8 bit. But after using CreateGDIPlusGraphicsFromImage() image is automatically converted to the 24 bit image. Why is it happening. This issue is very important to us plz
revert back ASAP.
 
#4 Posted : Wednesday, February 20, 2008 1:37:35 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

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


You
can use the ColorResolutionCommand Class to converts an image from any
bits-per-pixel to any bits-per-pixel. You can also use ColorResolutionCommand to apply the palette.


The
conversion from 8 to 24 bits when using CreateGDIPlusGraphicsFromImage, is a windows limitation when you create a GDI+ device context.

 
#5 Posted : Thursday, February 21, 2008 3:07:57 AM(UTC)
alwayssmiling

Groups: Registered
Posts: 27


Thank u for the suggestion i tried with the ColorResolutionCommand and changed bits per pixel to 8. It's changing the images bitsperpixel property.

ColorResolutionCommand cmd = new ColorResolutionCommand(); cmd.Mode = ColorResolutionCommandMode.InPlace;
cmd.BitsPerPixel = 8;
cmd.Run(jpegImage);

jpegImage.getPalette();
Now if i try to acess the palette for the image using
still i'm gettting the same error like invalid parameter.

based one of the examples provided i copied the same code in that case i'm getting the palette but i'm losing some image quality which shouldn't happen. The code is specified below,
ColorResolutionCommand cmd = new ColorResolutionCommand();
cmd.Mode ColorResolutionCommandMode.CreateDestinationImage;
cmd.BitsPerPixel = 8;
cmd.PaletteFlags = ColorResolutionCommandPaletteFlags.UsePalette;
cmd.SetPalette(RasterPalette.Netscape());
cmd.Run(image);

Is there any other by which i can get the palette of the image w/o losing the quality.
 
#6 Posted : Friday, February 22, 2008 5:16:35 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

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


If
you perform in-place color resolution, does the quality remain good? If yes,
this should not fail to give you a palette, and I tried similar code here and it worked.


Can
you create a small test program (not your full application) that isolates the problem, and send it to me in ZIP or RAR file. You can either send it to support@leadtools.com and mention this forum Post, or post it here (when attaching do not hit preview button).

 
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.096 seconds.