[FlagsAttribute()]public enum ChangeToImageOptions
| Value | Member | Description |
|---|---|---|
| 0x00000000 | None | Default |
| 0x00000001 | ForceChange | If the image is not GDI+ compatible, this flag forces the conversion. |
| 0x00000002 | NoPalette | Fail if the image has a palette. |
| 0x00000004 | TopLeftAlways | Force the image to have RasterViewPerspective.TopLeft view perspective. |
The ChangeToImageOptions are used as an options for the RasterImageConverter.ChangeToImage method.
For more information refer to RasterImage and GDI/GDI+.
using Leadtools;using Leadtools.Codecs;using Leadtools.Drawing;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;public void ChangeToImageExample(){RasterCodecs codecs = new RasterCodecs();string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "GdiPlusImage1.bmp");// Load the imageusing (RasterImage srcImage = codecs.Load(srcFileName)){// Convert to GDI+ imageImageIncompatibleReason reason = RasterImageConverter.TestCompatible(srcImage, true);PixelFormat pf = RasterImageConverter.GetNearestPixelFormat(srcImage);Console.WriteLine("TestCompatible: {0}", reason);Console.WriteLine("GetNearestPixelFormat:{0}", pf);if (reason != ImageIncompatibleReason.Compatible){RasterImageConverter.MakeCompatible(srcImage, pf, true);}using (Image destImage = RasterImageConverter.ChangeToImage(srcImage, ChangeToImageOptions.ForceChange)){// Save this image to diskdestImage.Save(destFileName, ImageFormat.Bmp);}}// Clean upcodecs.Dispose();}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";}