Class BmpImage

Class BmpImage

이름 공간 : Aspose.Imaging.FileFormats.Bmp 모임: Aspose.Imaging.dll (25.4.0)

Bitmap (BMP) 및 Device Independent Bitmap를 쉽게 처리할 수 있습니다.(DIB) 파일, 라스터의 효율적인 조작 및 처리를 촉진이미지에서 다양한 작업을 수행함으로써, 이 API는작업 흐름, 개발자에게 BMP와 함께 일할 수 있는 신뢰할 수 있는 도구 키트를 제공하고,그들의 소프트웨어 응용 프로그램에서 DIB 형식.

[JsonObject(MemberSerialization.OptIn)]
public sealed class BmpImage : RasterCachedImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata

Inheritance

object DisposableObject DataStreamSupporter Image RasterImage RasterCachedImage BmpImage

Implements

IDisposable , IObjectWithBounds , IRasterImageArgb32PixelLoader , IRasterImageRawDataLoader , IHasXmpData , IHasMetadata

상속 회원들

RasterCachedImage.CacheData() , RasterCachedImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedImage.Resize(int, int, ResizeType) , RasterCachedImage.Resize(int, int, ImageResizeSettings) , RasterCachedImage.RotateFlip(RotateFlipType) , RasterCachedImage.Rotate(float, bool, Color) , RasterCachedImage.Crop(Rectangle) , RasterCachedImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedImage.Grayscale() , RasterCachedImage.NormalizeHistogram() , RasterCachedImage.BinarizeFixed(byte) , RasterCachedImage.BinarizeOtsu() , RasterCachedImage.BinarizeBradley(double, int) , RasterCachedImage.BinarizeBradley(double) , RasterCachedImage.AdjustBrightness(int) , RasterCachedImage.AdjustContrast(float) , RasterCachedImage.AdjustGamma(float, float, float) , RasterCachedImage.AdjustGamma(float) , RasterCachedImage.IsCached , RasterImage.RemoveMetadata() , RasterImage.Save(Stream, ImageOptionsBase, Rectangle) , RasterImage.GetModifyDate(bool) , RasterImage.Dither(DitheringMethod, int) , RasterImage.Dither(DitheringMethod, int, IColorPalette) , RasterImage.GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings) , RasterImage.GetDefaultArgb32Pixels(Rectangle) , RasterImage.GetDefaultRawData(Rectangle, RawDataSettings) , RasterImage.GetArgb32Pixel(int, int) , RasterImage.GetPixel(int, int) , RasterImage.SetArgb32Pixel(int, int, int) , RasterImage.SetPixel(int, int, Color) , RasterImage.ReadScanLine(int) , RasterImage.ReadArgb32ScanLine(int) , RasterImage.WriteScanLine(int, Color[]) , RasterImage.WriteArgb32ScanLine(int, int[]) , RasterImage.LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.LoadPartialPixels(Rectangle, IPartialPixelLoader) , RasterImage.LoadArgb32Pixels(Rectangle) , RasterImage.LoadArgb64Pixels(Rectangle) , RasterImage.LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader) , RasterImage.LoadPixels(Rectangle) , RasterImage.LoadCmykPixels(Rectangle) , RasterImage.LoadCmyk32Pixels(Rectangle) , RasterImage.LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.SaveRawData(byte[], int, Rectangle, RawDataSettings) , RasterImage.SaveArgb32Pixels(Rectangle, int[]) , RasterImage.SavePixels(Rectangle, Color[]) , RasterImage.SaveCmykPixels(Rectangle, CmykColor[]) , RasterImage.SaveCmyk32Pixels(Rectangle, int[]) , RasterImage.SetResolution(double, double) , RasterImage.SetPalette(IColorPalette, bool) , RasterImage.Resize(int, int, ImageResizeSettings) , RasterImage.Rotate(float, bool, Color) , RasterImage.Rotate(float) , RasterImage.BinarizeFixed(byte) , RasterImage.BinarizeOtsu() , RasterImage.BinarizeBradley(double) , RasterImage.BinarizeBradley(double, int) , RasterImage.Blend(Point, RasterImage, Rectangle, byte) , RasterImage.Blend(Point, RasterImage, byte) , RasterImage.Grayscale() , RasterImage.NormalizeHistogram() , RasterImage.AdjustBrightness(int) , RasterImage.AdjustContrast(float) , RasterImage.AdjustGamma(float, float, float) , RasterImage.AdjustGamma(float) , RasterImage.GetSkewAngle() , RasterImage.NormalizeAngle() , RasterImage.NormalizeAngle(bool, Color) , RasterImage.Filter(Rectangle, FilterOptionsBase) , RasterImage.ReplaceColor(Color, byte, Color) , RasterImage.ReplaceColor(int, byte, int) , RasterImage.ReplaceNonTransparentColors(Color) , RasterImage.ReplaceNonTransparentColors(int) , RasterImage.ToBitmap() , RasterImage.PremultiplyComponents , RasterImage.UseRawData , RasterImage.UpdateXmpData , RasterImage.XmpData , RasterImage.RawIndexedColorConverter , RasterImage.RawCustomColorConverter , RasterImage.RawFallbackIndex , RasterImage.RawDataSettings , RasterImage.UsePalette , RasterImage.RawDataFormat , RasterImage.RawLineSize , RasterImage.IsRawDataAvailable , RasterImage.HorizontalResolution , RasterImage.VerticalResolution , RasterImage.HasTransparentColor , RasterImage.HasAlpha , RasterImage.TransparentColor , RasterImage.ImageOpacity , Image.CanLoad(string) , Image.CanLoad(string, LoadOptions) , Image.CanLoad(Stream) , Image.CanLoad(Stream, LoadOptions) , Image.Create(ImageOptionsBase, int, int) , Image.Create(Image[]) , Image.Create(MultipageCreateOptions) , Image.Create(string[], bool) , Image.Create(string[]) , Image.Create(Image[], bool) , Image.GetFileFormat(string) , Image.GetFileFormat(Stream) , Image.GetFittingRectangle(Rectangle, int, int) , Image.GetFittingRectangle(Rectangle, int[], int, int) , Image.Load(string, LoadOptions) , Image.Load(string) , Image.Load(Stream, LoadOptions) , Image.Load(Stream) , Image.GetProportionalWidth(int, int, int) , Image.GetProportionalHeight(int, int, int) , Image.RemoveMetadata() , Image.CanSave(ImageOptionsBase) , Image.Resize(int, int) , Image.Resize(int, int, ResizeType) , Image.Resize(int, int, ImageResizeSettings) , Image.GetDefaultOptions(object[]) , Image.GetOriginalOptions() , Image.ResizeWidthProportionally(int) , Image.ResizeHeightProportionally(int) , Image.ResizeWidthProportionally(int, ResizeType) , Image.ResizeHeightProportionally(int, ResizeType) , Image.ResizeWidthProportionally(int, ImageResizeSettings) , Image.ResizeHeightProportionally(int, ImageResizeSettings) , Image.RotateFlip(RotateFlipType) , Image.Rotate(float) , Image.Crop(Rectangle) , Image.Crop(int, int, int, int) , Image.Save() , Image.Save(string) , Image.Save(string, ImageOptionsBase) , Image.Save(string, ImageOptionsBase, Rectangle) , Image.Save(Stream, ImageOptionsBase) , Image.Save(Stream, ImageOptionsBase, Rectangle) , Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , Image.SetPalette(IColorPalette, bool) , Image.BitsPerPixel , Image.Bounds , Image.Container , Image.Height , Image.Palette , Image.UsePalette , Image.Size , Image.Width , Image.InterruptMonitor , Image.BufferSizeHint , Image.AutoAdjustPalette , Image.HasBackgroundColor , Image.FileFormat , Image.BackgroundColor , DataStreamSupporter.CacheData() , DataStreamSupporter.Save() , DataStreamSupporter.Save(Stream) , DataStreamSupporter.Save(string) , DataStreamSupporter.Save(string, bool) , DataStreamSupporter.DataStreamContainer , DataStreamSupporter.IsCached , DisposableObject.Dispose() , DisposableObject.Disposed , object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

DXT1 압축 알고리즘을 사용하여 이전에 압축 된 BMP 이미지를 압축합니다.

using (var image = Image.Load("CompressedTiger.bmp"))
                                                                                                 {
                                                                                                     image.Save("DecompressedTiger.bmp", new BmpOptions());
                                                                                                 }

DXT1 압축 알고리즘을 사용하여 BMP 이미지를 압축합니다.

using (var image = Image.Load("Tiger.bmp"))
                                                               {
                                                                   image.Save("CompressedTiger.bmp", new BmpOptions { Compression = BitmapCompression.Dxt1 });
                                                               }

예제는 Telea 알고리즘을 사용하여 그래픽 경로를 사용하여 이미지에서 어떤 개체를 제거하는 방법을 보여줍니다.

var imageFilePath = "ball.png"; 
                                                                                                              using (var image = Image.Load(imageFilePath))
                                                                                                              {
                                                                                                                  var pngImage = (PngImage)image;

                                                                                                                  var mask = new GraphicsPath();
                                                                                                                  var firstFigure = new Figure();
                                                                                                                  firstFigure.AddShape(new EllipseShape(new RectangleF(350, 170, 570 - 350, 400 - 170)));
                                                                                                                  mask.AddFigure(firstFigure);

                                                                                                                  var options = new TeleaWatermarkOptions(mask);

                                                                                                                  var result = WatermarkRemover.PaintOver(pngImage, options);

                                                                                                                  result.Save(outputPath);
                                                                                                              }

예제는 Rgb 압축 유형을 사용하여 BmpImage를 수출하는 방법을 보여줍니다.

string sourcePath = "input.png";
                                                                                    // Load a PNG image from a file.
                                                                                    using (Image pngImage = Image.Load(sourcePath))
                                                                                    {
                                                                                        // BMP image is saved with transparency support by default, that is achieved by using the BitmapCompression.Bitfields compression method. 
                                                                                        // To save a BMP image with the Rgb compression method, the BmpOptions with the Compression property set to BitmapCompression.Rgb should be specified.
                                                                                        pngImage.Save(outputPath, new BmpOptions() { Compression = BitmapCompression.Rgb });
                                                                                    }

예제는 콘텐츠 알고리즘을 사용하여 그래픽 경로를 사용하여 이미지에서 어떤 개체를 제거하는 방법을 보여줍니다.

var imageFilePath = "ball.png"; 
                                                                                                                           using (var image = Image.Load(imageFilePath))
                                                                                                                           {
                                                                                                                               var pngImage = (PngImage)image;

                                                                                                                               var mask = new GraphicsPath();
                                                                                                                               var firstFigure = new Figure();
                                                                                                                               firstFigure.AddShape(new EllipseShape(new RectangleF(350, 170, 570 - 350, 400 - 170)));
                                                                                                                               mask.AddFigure(firstFigure);

                                                                                                                               var options = new ContentAwareFillWatermarkOptions(mask) 
                                                                                                                               { 
                                                                                                                                   MaxPaintingAttempts = 4
                                                                                                                               };

                                                                                                                               var result = WatermarkRemover.PaintOver(pngImage, options);

                                                                                                                               result.Save(outputPath);
                                                                                                                           }

다음 예제는 지정된 크기의 BMP 이미지를 만드는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                                       // Create a BMP image 100 x 100 px.
                                                                                       using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100))
                                                                                       {
                                                                                           // Fill the image with a simple linear red-black gradient.
                                                                                           int width = bmpImage.Width;
                                                                                           int height = bmpImage.Height;
                                                                                           for (int y = 0; y < height; y++)
                                                                                           {
                                                                                               for (int x = 0; x < width; x++)
                                                                                               {
                                                                                                   int hue = (255 * x) / width;
                                                                                                   bmpImage.SetPixel(x, y, Aspose.Imaging.Color.FromArgb(255, hue, 0, 0));
                                                                                               }
                                                                                           }

                                                                                           using (System.IO.FileStream stream = new System.IO.FileStream(dir + "output.bmp", System.IO.FileMode.Create))
                                                                                           {
                                                                                               bmpImage.Save(stream);
                                                                                           }
                                                                                       }

예제는 알파 채널을 유지하는 동안 Png 파일에서 BmpImage를 수출하는 방법을 보여주며, Bmp 파일을 투명하게 저장합니다.

string sourcePath = "input.png";
                                                                                                                                         // Load a PNG image from a file.
                                                                                                                                         using (Image pngImage = Image.Load(sourcePath))
                                                                                                                                         {
                                                                                                                                             // BMP image is saved with transparency support by default. 
                                                                                                                                             // If you want to explicitly specify such mode, the BmpOptions's Compression property should be set to BitmapCompression.Bitfields.
                                                                                                                                             // The BitmapCompression.Bitfields compression method is the default compression method in the BmpOptions.
                                                                                                                                             // So the same result of exporting a Bmp image with transparency can be achieved by either one of the following ways.
                                                                                                                                             // With an implicit default options:
                                                                                                                                             pngImage.Save(outputPath);
                                                                                                                                             // With an explicit default options:
                                                                                                                                             pngImage.Save(outputPath, new BmpOptions());
                                                                                                                                             // Specifying the BitmapCompression.Bitfields compression method:
                                                                                                                                             pngImage.Save(outputPath, new BmpOptions() { Compression = BitmapCompression.Bitfields });
                                                                                                                                         }

Constructors

BmpImage(스트리트)

BmpImage 클래스를 쉽게 사용하기 시작하십시오.이 건축기와 함께새로운 사례를 시작합니다. 개발자를위한 완벽하고Aspose.Imaging.FileFormats.Bmp.BmpImage 객체를 빠르고 효율적으로 실행합니다.

public BmpImage(string path)

Parameters

path string

이미지를 로드하고 픽셀과 팔레트 데이터를 시작하는 경로.

Examples

예제는 파일에서 BmpImage를 업로드하는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                // Load a BMP image from a file.
                                                                // The source pixels will be converted to 32-bpp format if required.
                                                                using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(dir + "sample.bmp"))
                                                                {
                                                                    // Do some image processing.
                                                                    // Save to another BMP file.
                                                                    bmpImage.Save(dir + "sample.output.32bpp.bmp");
                                                                }

Exceptions

ArgumentNullException

라스터 이미지는 0입니다.

BmpImageException

높이가 긍정적이어야 합니다.

ArgumentException

팔레트는 픽셀 당 8비트 이상의 이미지에 대해 지정되어야 합니다.

BmpImage(링, ushort, BitmapCompression, 이중, 이중)

이 디자이너와 함께 Aspose.Imaging.FileFormats.Bmp.BmpImage 클래스의 새로운 예를 쉽게 만들고,경로, bitsPerPixel 및 압축과 같은 지정된 매개 변수를 사용합니다.BmpImage 개체를 빠르고 효율적으로, 정확한 제어로 시작하려고 합니다.이미지 특성에 대하여

public BmpImage(string path, ushort bitsPerPixel, BitmapCompression compression, double horizontalResolution, double verticalResolution)

Parameters

path string

이미지를 로드하고 픽셀과 팔레트 데이터를 시작하는 경로.

bitsPerPixel ushort

픽셀 당 비트

compression BitmapCompression

사용하기 위한 압축

horizontalResolution double

수평 해상도 : 회전으로 인해 결과 해상도는 과거 해상도와 약간 다를 수 있습니다.

verticalResolution double

회전으로 인해 결과의 해상도는 과거의 해상도와 약간 다를 수 있습니다.

Examples

예제는 지정된 비트 깊이와 해상도를 가진 파일에서 BmpImage를 업로드하는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                                                            // Load a BMP image from a file.
                                                                                                            // The source pixels will be converted to 24-bpp format if required.
                                                                                                            // The resolution will be set to 96 dpi.
                                                                                                            using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage =
                                                                                                                new Aspose.Imaging.FileFormats.Bmp.BmpImage(dir + "sample.bmp", 24, Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb, 96.0, 96.0))
                                                                                                            {
                                                                                                                // Do some image processing.
                                                                                                                // Save to another BMP file.
                                                                                                                bmpImage.Save(dir + "sample.output.24bpp.96dpi.bmp");
                                                                                                            }

Exceptions

ArgumentNullException

라스터 이미지는 0입니다.

BmpImageException

높이가 긍정적이어야 합니다.

ArgumentException

팔레트는 픽셀 당 8비트 이상의 이미지에 대해 지정되어야 합니다.

BmpImage(Stream)

Aspose.Imaging.FileFormats.Bmp.BmpImage 클래스를 쉽게 사용하여 새로운 예제를 시작하십시오.이 건축기와 함께, 입력으로 흐름을 사용합니다.이 개발자를 위해 완벽합니다.다양한 데이터 소스에서 BmpImage 개체를 사용하는 편리한 방법,융통성과 통합의 쉬움을 보장합니다.

public BmpImage(Stream stream)

Parameters

stream Stream

흐름에서 이미지를 로드하고 픽셀과 팔레트 데이터를 시작합니다.

Examples

예제는 파일 스트림에서 BmpImage를 업로드하는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                       // Load a BMP image from a file stream.
                                                                       // The source pixels will be converted to 32-bpp format if required.
                                                                       using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.bmp"))
                                                                       {
                                                                           using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(stream))
                                                                           {
                                                                               // Do some image processing.
                                                                               // Save to another BMP file.
                                                                               bmpImage.Save(dir + "sample.output.32bpp.bmp");
                                                                           }
                                                                       }

Exceptions

ArgumentNullException

라스터 이미지는 0입니다.

BmpImageException

높이가 긍정적이어야 합니다.

ArgumentException

팔레트는 픽셀 당 8비트 이상의 이미지에 대해 지정되어야 합니다.

BmpImage(스트림, ushort, BitmapCompression, 이중, 이중)

Aspose.Imaging.FileFormats.Bmp.BmpImage 클래스를 사용하여 작업을 시작하십시오.흐름을 사용하여 새로운 사례, bitsPerPixel과 같은 지정된 매개 변수와 함께그리고 압축.그것을 처리하는 간단한 방법을 찾는 개발자를위한 완벽한BmpImage 개체는 프로젝트의 유연성과 효율성을 보장합니다.

public BmpImage(Stream stream, ushort bitsPerPixel, BitmapCompression compression, double horizontalResolution, double verticalResolution)

Parameters

stream Stream

흐름에서 이미지를 로드하고 픽셀과 팔레트 데이터를 시작합니다.

bitsPerPixel ushort

픽셀 당 비트

compression BitmapCompression

사용하기 위한 압축

horizontalResolution double

수평 해상도 : 회전으로 인해 결과 해상도는 과거 해상도와 약간 다를 수 있습니다.

verticalResolution double

회전으로 인해 결과의 해상도는 과거의 해상도와 약간 다를 수 있습니다.

Examples

예제는 지정된 비트 깊이와 해상도로 파일 스트림에서 BmpImage를 로드하는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                                                                   // Load a BMP image from a file stream.
                                                                                                                   // The source pixels will be converted to 24-bpp format if required.
                                                                                                                   // The resolution will be set to 96 dpi.
                                                                                                                   using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.bmp"))
                                                                                                                   {
                                                                                                                       using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage =
                                                                                                                           new Aspose.Imaging.FileFormats.Bmp.BmpImage(stream, 24, Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb, 96.0, 96.0))
                                                                                                                       {
                                                                                                                           // Do some image processing.
                                                                                                                           // Save to another BMP file.
                                                                                                                           bmpImage.Save(dir + "sample.output.24bpp.96dpi.bmp");
                                                                                                                       }
                                                                                                                   }

Exceptions

ArgumentNullException

라스터 이미지는 0입니다.

BmpImageException

높이가 긍정적이어야 합니다.

ArgumentException

팔레트는 픽셀 당 8비트 이상의 이미지에 대해 지정되어야 합니다.

BmpImage(RasterImage)

쉽게 Aspose.Imaging.FileFormats.Bmp.BmpImage 클래스의 새로운 예를 만들기RasterImage 개체로 시작함으로써 개발자를 위해 완벽합니다.기존의 래스터 이미지를 BmpImage 형식으로 무작위로 변환하여그들의 프로젝트에 적합성과 통합의 쉬움.

public BmpImage(RasterImage rasterImage)

Parameters

rasterImage RasterImage

이미지와 함께 픽셀 및 팔레트 데이터를 시작합니다.

Examples

예제는 RasterImage의 다른 예에서 BmpImage를 업로드하는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                                         // Create a new PNG image.
                                                                                         Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                         createOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
                                                                                         using (Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(createOptions, 100, 100))
                                                                                         {
                                                                                             // Fill the entire PNG image in red.
                                                                                             Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(rasterImage);
                                                                                             Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                             gr.FillRectangle(brush, rasterImage.Bounds);

                                                                                             // Create a BMP image based on the PNG image.
                                                                                             // The source pixels will be converted to 32-bpp format if required.
                                                                                             using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(rasterImage))
                                                                                             {
                                                                                                 // Save to a BMP file
                                                                                                 bmpImage.Save(dir + "output.32bpp.bmp");
                                                                                             }
                                                                                         }

Exceptions

ArgumentNullException

라스터 이미지는 0입니다.

BmpImageException

높이가 긍정적이어야 합니다.

ArgumentException

팔레트는 픽셀 당 8비트 이상의 이미지에 대해 지정되어야 합니다.

BmpImage(RasterImage, ushort, BitmapCompression, 이중, 이중)

Aspose.Imaging.FileFormats.Bmp.BmpImage 클래스와 함께 작업을 시작하여 새로운 사례를 생성합니다.rasterImage를 사용하여 bitsPerPixel 및 압축과 같은 지정된 매개 변수와 함께.BmpImage 개체를 처리하는 간단한 방법을 찾는 개발자를위한 완벽한,그들의 프로젝트에서 유연성과 효율성을 보장합니다.

public BmpImage(RasterImage rasterImage, ushort bitsPerPixel, BitmapCompression compression, double horizontalResolution, double verticalResolution)

Parameters

rasterImage RasterImage

이미지와 함께 픽셀 및 팔레트 데이터를 시작합니다.

bitsPerPixel ushort

픽셀 당 비트

compression BitmapCompression

사용하기 위한 압축

horizontalResolution double

수평 해상도 : 회전으로 인해 결과 해상도는 과거 해상도와 약간 다를 수 있습니다.

verticalResolution double

회전으로 인해 결과의 해상도는 과거의 해상도와 약간 다를 수 있습니다.

Examples

예제는 지정된 비트 깊이와 압축으로 다른 RasterImage 인스턴스에서 BmpImage를 충전하는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                                                                                      // Create a new PNG image.
                                                                                                                                      Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                                      createOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
                                                                                                                                      using (Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(createOptions, 100, 100))
                                                                                                                                      {
                                                                                                                                          // Fill the entire PNG image in red.
                                                                                                                                          Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(rasterImage);
                                                                                                                                          Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                                                                          gr.FillRectangle(brush, rasterImage.Bounds);

                                                                                                                                          // Create a BMP image based on the PNG image.
                                                                                                                                          // The source pixels will be converted to 24-bpp format if required.
                                                                                                                                          // The resolution will be set to 96 dpi.
                                                                                                                                          using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(rasterImage, 24, Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb, 96.0, 96.0))
                                                                                                                                          {
                                                                                                                                              // Save to a BMP file
                                                                                                                                              bmpImage.Save(dir + "output.24bpp.96dpi.bmp");
                                                                                                                                          }
                                                                                                                                      }

Exceptions

ArgumentNullException

라스터 이미지는 0입니다.

BmpImageException

높이가 긍정적이어야 합니다.

ArgumentException

팔레트는 픽셀 당 8비트 이상의 이미지에 대해 지정되어야 합니다.

BmpImage(이트, 이트)

Aspose.Imaging.FileFormats.Bmp.BmpImage 클래스를 쉽게 사용하여 새로운 예제를 만들기 시작합니다.특정 폭 및 높이 매개 변수와 함께. 개발자가 찾고있는 이상적인사용자 지정 크기의 BmpImage 개체를 생성하는 편리한 방법, 보장그들의 프로젝트에 대한 유연성과 통합의 쉬움.

public BmpImage(int width, int height)

Parameters

width int

그림의 넓이.

height int

이미지 높이 입니다.

Examples

예제는 지정된 크기의 BmpImage를 만드는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                            // Create a 32-bpp BMP image of 100 x 100 px.
                                                                            using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100))
                                                                            {
                                                                                // Fill the entire image in red.
                                                                                Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);
                                                                                Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                gr.FillRectangle(brush, bmpImage.Bounds);

                                                                                // Save to a BMP file
                                                                                bmpImage.Save(dir + "output.bmp");
                                                                            }

다음 예제는 출력 크기를 줄이기 위해 BMP 이미지를 팔레트화하는 방법을 보여줍니다.

// Create a BMP image 100 x 100 px.
                                                                                              using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100))
                                                                                              {
                                                                                                  // The linear gradient from the left-top to the right-bottom corner of the image.
                                                                                                  Aspose.Imaging.Brushes.LinearGradientBrush brush =
                                                                                                      new Aspose.Imaging.Brushes.LinearGradientBrush(
                                                                                                          new Aspose.Imaging.Point(0, 0),
                                                                                                          new Aspose.Imaging.Point(bmpImage.Width, bmpImage.Height),
                                                                                                          Aspose.Imaging.Color.Red,
                                                                                                          Aspose.Imaging.Color.Green);

                                                                                                  // Fill the entire image with the linear gradient brush.
                                                                                                  Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);
                                                                                                  gr.FillRectangle(brush, bmpImage.Bounds);

                                                                                                  // Get the closest 8-bit color palette which covers as many pixels as possible, so that a palettized image
                                                                                                  // is almost visually indistinguishable from a non-palletized one.
                                                                                                  Aspose.Imaging.IColorPalette palette = Aspose.Imaging.ColorPaletteHelper.GetCloseImagePalette(bmpImage, 256);

                                                                                                  // 8-bit palette contains at most 256 colors.
                                                                                                  Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
                                                                                                  saveOptions.Palette = palette;
                                                                                                  saveOptions.BitsPerPixel = 8;

                                                                                                  using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                  {
                                                                                                      bmpImage.Save(stream, saveOptions);
                                                                                                      System.Console.WriteLine("The palettized image size is {0} bytes.", stream.Length);
                                                                                                  }

                                                                                                  using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                  {
                                                                                                      bmpImage.Save(stream);
                                                                                                      System.Console.WriteLine("The non-palettized image size is {0} bytes.", stream.Length);
                                                                                                  }
                                                                                              }

                                                                                              // The output looks like this:
                                                                                              // The palettized image size is 11078 bytes.
                                                                                              // The non-palettized image size is 40054 bytes.

Exceptions

BmpImageException

높이가 긍정적이어야 합니다.

ArgumentException

팔레트는 픽셀 당 8비트 이상의 이미지에 대해 지정되어야 합니다.

BmpImage(인트, 인트, ushort, IColorPalette)

Aspose.Imaging.FileFormats.Bmp.BmpImage 클래스를 무조건 사용하여 새로운 사례를 시작하십시오.폭, 높이, 조각 깊이 및 팔레트와 같은 매개 변수와 함께.개발자는 BmpImage 개체를 만들 수있는 간단한 방법을 찾고 있습니다.사용자 지정 차원 및 색상 구성, 그들의 프로젝트의 유연성과 효율성을 보장.

public BmpImage(int width, int height, ushort bitsPerPixel, IColorPalette palette)

Parameters

width int

그림의 넓이.

height int

이미지 높이 입니다.

bitsPerPixel ushort

픽셀 당 비트

palette IColorPalette

색상 팔레트

Examples

예제는 지정된 팔레트를 사용하여 지정된 크기의 BmpImage를 만드는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                                                       Aspose.Imaging.Color[] paletterColors = new Aspose.Imaging.Color[]
                                                                                                       {
                                                                                                           Aspose.Imaging.Color.Red,
                                                                                                           Aspose.Imaging.Color.Green,
                                                                                                       };

                                                                                                       // Create a monochrome palette which contains only red and green colors.
                                                                                                       Aspose.Imaging.IColorPalette palette = new Aspose.Imaging.ColorPalette(paletterColors);

                                                                                                       // Create a monochrome 1-bpp BMP image of 100 x 100 px.
                                                                                                       using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 1, palette))
                                                                                                       {
                                                                                                           Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);

                                                                                                           // Fill the upper half of the image in red.
                                                                                                           Aspose.Imaging.Brushes.SolidBrush redBrush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                                           gr.FillRectangle(redBrush, new Aspose.Imaging.Rectangle(0, 0, bmpImage.Width, bmpImage.Height / 2));

                                                                                                           // Fill the lower half of the image in green.
                                                                                                           Aspose.Imaging.Brushes.SolidBrush greenBrush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Green);
                                                                                                           gr.FillRectangle(greenBrush, new Aspose.Imaging.Rectangle(0, bmpImage.Height / 2, bmpImage.Width, bmpImage.Height / 2));

                                                                                                           // Save to BMP
                                                                                                           bmpImage.Save(dir + "output.monochrome.bmp");
                                                                                                       }

Exceptions

BmpImageException

높이가 긍정적이어야 합니다.

ArgumentException

팔레트는 픽셀 당 8비트 이상의 이미지에 대해 지정되어야 합니다.

BmpImage(int, int, ushort, IColorPalette, BitmapCompression, 이중, 이중)

이 디자이너와 함께 Aspose.Imaging.FileFormats.Bmp.BmpImage 클래스의 새로운 예를 쉽게 만들고,폭, 높이, bitsPerPixel 및 팔레트와 같은 매개 변수를 지정합니다.사용자 지정 크기로 BmpImage 개체를 생성하는 편리한 방법을 찾고 있습니다.그리고 색상 구성, 그들의 프로젝트에 대한 유연성과 통합의 쉬움을 보장.

public BmpImage(int width, int height, ushort bitsPerPixel, IColorPalette palette, BitmapCompression compression, double horizontalResolution, double verticalResolution)

Parameters

width int

그림의 넓이.

height int

이미지 높이 입니다.

bitsPerPixel ushort

픽셀 당 비트

palette IColorPalette

색상 팔레트

compression BitmapCompression

사용하기 위한 압축

horizontalResolution double

수평 해상도 : 회전으로 인해 결과 해상도는 과거 해상도와 약간 다를 수 있습니다.

verticalResolution double

회전으로 인해 결과의 해상도는 과거의 해상도와 약간 다를 수 있습니다.

Examples

예제는 다양한 옵션을 사용하여 BmpImage를 만드는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                            Aspose.Imaging.Color[] paletterColors = new Aspose.Imaging.Color[]
                                                                            {
                                                                                Aspose.Imaging.Color.Red,
                                                                                Aspose.Imaging.Color.Green,
                                                                            };

                                                                            // Create a monochrome palette which contains only red and green colors.
                                                                            Aspose.Imaging.IColorPalette palette = new Aspose.Imaging.ColorPalette(paletterColors);

                                                                            // Create a monochrome 1-bpp BMP image of 100 x 100 px.
                                                                            // The horizontal and vertical resolution will be set to 96 dpi.
                                                                            using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 1, palette, Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb, 96.0, 96.0))
                                                                            {
                                                                                Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);

                                                                                // Fill the upper half of the image in red.
                                                                                Aspose.Imaging.Brushes.SolidBrush redBrush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                gr.FillRectangle(redBrush, new Aspose.Imaging.Rectangle(0, 0, bmpImage.Width, bmpImage.Height / 2));

                                                                                // Fill the lower half of the image in green.
                                                                                Aspose.Imaging.Brushes.SolidBrush greenBrush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Green);
                                                                                gr.FillRectangle(greenBrush, new Aspose.Imaging.Rectangle(0, bmpImage.Height / 2, bmpImage.Width, bmpImage.Height / 2));

                                                                                // Save to a BMP file
                                                                                bmpImage.Save(dir + "output.monochrome.96dpi.bmp");
                                                                            }

Exceptions

BmpImageException

높이가 긍정적이어야 합니다.

ArgumentException

팔레트는 픽셀 당 8비트 이상의 이미지에 대해 지정되어야 합니다.

Properties

BitmapInfoHeader

이 간단한 기능을 사용하여 비트 맵 이미지에 대한 필수 세부 사항에 빠르게 액세스하십시오.개발자가 자신의 이미지에 대한 헤더 정보를 얻을 필요가있는 데 완벽합니다.

public BitmapInfoHeader BitmapInfoHeader { get; }

부동산 가치

BitmapInfoHeader

Examples

다음 예제는 BMP 헤더에서 정보를 얻고 콘솔에 인쇄합니다.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.bmp"))
                                                                                                       {
                                                                                                           Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;
                                                                                                           Aspose.Imaging.FileFormats.Bmp.BitmapInfoHeader header = bmpImage.BitmapInfoHeader;

                                                                                                           System.Console.WriteLine("The number of palette colors that are required for displaying the bitmap: {0}", header.BitmapColorsImportant);
                                                                                                           System.Console.WriteLine("The number of palette colors used in the bitmap: {0}", header.BitmapColorsUsed);
                                                                                                           System.Console.WriteLine("The bitmap compression: {0}", header.BitmapCompression);
                                                                                                           System.Console.WriteLine("The bitmap height: {0}", header.BitmapHeight);
                                                                                                           System.Console.WriteLine("The bitmap width: {0}", header.BitmapWidth);
                                                                                                           System.Console.WriteLine("The bitmap raw data size in bytes: {0}", header.BitmapImageSize);
                                                                                                           System.Console.WriteLine("The number of planes: {0}", header.BitmapPlanes);
                                                                                                           System.Console.WriteLine("The horizontal resolution of the bitmap, in pixels-per-meter: {0}", header.BitmapXPelsPerMeter);
                                                                                                           System.Console.WriteLine("The vertical resolution of the bitmap, in pixels-per-meter: {0}", header.BitmapYPelsPerMeter);
                                                                                                           System.Console.WriteLine("The number of bits per pixel: {0}", header.BitsPerPixel);
                                                                                                           System.Console.WriteLine("The extra bits masks: {0}", header.ExtraBitMasks);
                                                                                                           System.Console.WriteLine("The header size in bytes: {0}", header.HeaderSize);
                                                                                                       }

                                                                                                       //The output may look like this:
                                                                                                       //The number of palette colors that are required for displaying the bitmap: 0
                                                                                                       //The number of palette colors used in the bitmap: 0
                                                                                                       //The bitmap compression: 0
                                                                                                       //The bitmap height: 375
                                                                                                       //The bitmap width: 500
                                                                                                       //The bitmap raw data size in bytes: 562500
                                                                                                       //The number of planes: 1
                                                                                                       //The horizontal resolution of the bitmap, in pixels-per-meter: 0
                                                                                                       //The vertical resolution of the bitmap, in pixels-per-meter: 0
                                                                                                       //The number of bits per pixel: 24
                                                                                                       //The extra bits masks: 
                                                                                                       //The header size in bytes: 40

BitsPerPixel

이 속성을 사용하여 이미지에 대한 픽셀 당 비트 수에 쉽게 액세스할 수 있습니다.이미지 품질과 깊이에 대한 빠른 정보를 찾는 개발자를위한 완벽합니다.

public override int BitsPerPixel { get; }

부동산 가치

int

Examples

다음 예제는 픽셀 형식, 이미지 크기, 해상도, 압축 등을 포함하여 이미지에 대한 일반적인 정보를 얻습니다.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.bmp"))
                                                                                                                                              {
                                                                                                                                                  Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;                

                                                                                                                                                  System.Console.WriteLine("The pixel format: {0}", bmpImage.RawDataFormat);                
                                                                                                                                                  System.Console.WriteLine("The raw line size in bytes: {0}", bmpImage.RawLineSize);
                                                                                                                                                  System.Console.WriteLine("The bitmap compression: {0}", bmpImage.Compression);
                                                                                                                                                  System.Console.WriteLine("The bitmap width: {0}", bmpImage.Width);
                                                                                                                                                  System.Console.WriteLine("The bitmap height: {0}", bmpImage.Height);
                                                                                                                                                  System.Console.WriteLine("The number of bits per pixel: {0}", bmpImage.BitsPerPixel);

                                                                                                                                                  double hres = bmpImage.HorizontalResolution;
                                                                                                                                                  double vres = bmpImage.VerticalResolution;
                                                                                                                                                  System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", hres);
                                                                                                                                                  System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", vres);

                                                                                                                                                  if (hres != 96.0 || vres != 96.0)
                                                                                                                                                  {
                                                                                                                                                      // You may consider using the SetResolution method for updating both resolution values in single call.
                                                                                                                                                      System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                                                                      bmpImage.SetResolution(96.0, 96.0);

                                                                                                                                                      System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", bmpImage.HorizontalResolution);
                                                                                                                                                      System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", bmpImage.VerticalResolution);
                                                                                                                                                  }

                                                                                                                                                  //The output may look like this:
                                                                                                                                                  //The pixel format: Rgb24Bpp, used channels: 8,8,8
                                                                                                                                                  //The raw line size in bytes: 1500
                                                                                                                                                  //The bitmap compression: Rgb
                                                                                                                                                  //The bitmap width: 500
                                                                                                                                                  //The bitmap height: 375
                                                                                                                                                  //The number of bits per pixel: 24
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 0
                                                                                                                                                  //The vertical resolution, in pixels per inch: 0
                                                                                                                                                  //Set resolution values to 96 dpi
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 96.012
                                                                                                                                                  //The vertical resolution, in pixels per inch: 96.012
                                                                                                                                              }

다음 예제는 bitmap 압축이 출력 이미지 크기에 어떤 영향을 미치는지 보여줍니다.

Aspose.Imaging.FileFormats.Bmp.BitmapCompression[] compressions = new Aspose.Imaging.FileFormats.Bmp.BitmapCompression[]
                                                                                                {
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb,
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rle8,
                                                                                                };

                                                                                                Aspose.Imaging.Color[] paletterColors = new Aspose.Imaging.Color[]
                                                                                                {
                                                                                                    Aspose.Imaging.Color.Red,
                                                                                                    Aspose.Imaging.Color.Green,
                                                                                                };

                                                                                                // Create a monochrome palette which contains only red and green colors.
                                                                                                Aspose.Imaging.IColorPalette palette = new Aspose.Imaging.ColorPalette(paletterColors);

                                                                                                foreach (Aspose.Imaging.FileFormats.Bmp.BitmapCompression compression in compressions)
                                                                                                {
                                                                                                    // Create a 8-bpp BMP image of 100 x 100 px.
                                                                                                    using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 8, palette, compression, 0.0, 0.0))
                                                                                                    {
                                                                                                        Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);

                                                                                                        // Fill the entire image in red.
                                                                                                        Aspose.Imaging.Brushes.SolidBrush redBrush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                                        gr.FillRectangle(redBrush, bmpImage.Bounds);

                                                                                                        // Save the image to a stream to get the output image size.
                                                                                                        using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                        {
                                                                                                            bmpImage.Save(stream);

                                                                                                            System.Console.WriteLine("---------------------------------------------");
                                                                                                            System.Console.WriteLine("The compression={0}", bmpImage.Compression);
                                                                                                            System.Console.WriteLine("The number of bits per pixel={0}", bmpImage.BitsPerPixel);
                                                                                                            System.Console.WriteLine("The image dimensions={0} x {1}", bmpImage.Width, bmpImage.Height);
                                                                                                            System.Console.WriteLine("The raw line size={0}", bmpImage.RawLineSize);
                                                                                                            System.Console.WriteLine("The output size in bytes={0}", stream.Length);
                                                                                                        }
                                                                                                    }
                                                                                                }

                                                                                                // The output looks like this:
                                                                                                // ---------------------------------------------
                                                                                                // The compression = Rgb
                                                                                                // The number of bits per pixel = 8
                                                                                                // The image dimensions = 100 x 100
                                                                                                // The raw line size = 100
                                                                                                // The output size in bytes = 11078
                                                                                                // ---------------------------------------------
                                                                                                // The compression = Rle8
                                                                                                // The number of bits per pixel = 8
                                                                                                // The image dimensions = 100 x 100
                                                                                                // The raw line size = 100
                                                                                                // The output size in bytes = 856

Compression

이 속성으로 이미지에 사용되는 압축 유형을 쉽게 복구하십시오.개발자가 이미지 압축에 관한 정보를 신속하게 접근해야하는 데 적합합니다.

public BitmapCompression Compression { get; }

부동산 가치

BitmapCompression

Examples

다음 예제는 픽셀 형식, 이미지 크기, 해상도, 압축 등을 포함하여 이미지에 대한 일반적인 정보를 얻습니다.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.bmp"))
                                                                                                                                              {
                                                                                                                                                  Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;                

                                                                                                                                                  System.Console.WriteLine("The pixel format: {0}", bmpImage.RawDataFormat);                
                                                                                                                                                  System.Console.WriteLine("The raw line size in bytes: {0}", bmpImage.RawLineSize);
                                                                                                                                                  System.Console.WriteLine("The bitmap compression: {0}", bmpImage.Compression);
                                                                                                                                                  System.Console.WriteLine("The bitmap width: {0}", bmpImage.Width);
                                                                                                                                                  System.Console.WriteLine("The bitmap height: {0}", bmpImage.Height);
                                                                                                                                                  System.Console.WriteLine("The number of bits per pixel: {0}", bmpImage.BitsPerPixel);

                                                                                                                                                  double hres = bmpImage.HorizontalResolution;
                                                                                                                                                  double vres = bmpImage.VerticalResolution;
                                                                                                                                                  System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", hres);
                                                                                                                                                  System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", vres);

                                                                                                                                                  if (hres != 96.0 || vres != 96.0)
                                                                                                                                                  {
                                                                                                                                                      // You may consider using the SetResolution method for updating both resolution values in single call.
                                                                                                                                                      System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                                                                      bmpImage.SetResolution(96.0, 96.0);

                                                                                                                                                      System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", bmpImage.HorizontalResolution);
                                                                                                                                                      System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", bmpImage.VerticalResolution);
                                                                                                                                                  }

                                                                                                                                                  //The output may look like this:
                                                                                                                                                  //The pixel format: Rgb24Bpp, used channels: 8,8,8
                                                                                                                                                  //The raw line size in bytes: 1500
                                                                                                                                                  //The bitmap compression: Rgb
                                                                                                                                                  //The bitmap width: 500
                                                                                                                                                  //The bitmap height: 375
                                                                                                                                                  //The number of bits per pixel: 24
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 0
                                                                                                                                                  //The vertical resolution, in pixels per inch: 0
                                                                                                                                                  //Set resolution values to 96 dpi
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 96.012
                                                                                                                                                  //The vertical resolution, in pixels per inch: 96.012
                                                                                                                                              }

다음 예제는 bitmap 압축이 출력 이미지 크기에 어떤 영향을 미치는지 보여줍니다.

Aspose.Imaging.FileFormats.Bmp.BitmapCompression[] compressions = new Aspose.Imaging.FileFormats.Bmp.BitmapCompression[]
                                                                                                {
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb,
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rle8,
                                                                                                };

                                                                                                Aspose.Imaging.Color[] paletterColors = new Aspose.Imaging.Color[]
                                                                                                {
                                                                                                    Aspose.Imaging.Color.Red,
                                                                                                    Aspose.Imaging.Color.Green,
                                                                                                };

                                                                                                // Create a monochrome palette which contains only red and green colors.
                                                                                                Aspose.Imaging.IColorPalette palette = new Aspose.Imaging.ColorPalette(paletterColors);

                                                                                                foreach (Aspose.Imaging.FileFormats.Bmp.BitmapCompression compression in compressions)
                                                                                                {
                                                                                                    // Create a 8-bpp BMP image of 100 x 100 px.
                                                                                                    using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 8, palette, compression, 0.0, 0.0))
                                                                                                    {
                                                                                                        Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);

                                                                                                        // Fill the entire image in red.
                                                                                                        Aspose.Imaging.Brushes.SolidBrush redBrush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                                        gr.FillRectangle(redBrush, bmpImage.Bounds);

                                                                                                        // Save the image to a stream to get the output image size.
                                                                                                        using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                        {
                                                                                                            bmpImage.Save(stream);

                                                                                                            System.Console.WriteLine("---------------------------------------------");
                                                                                                            System.Console.WriteLine("The compression={0}", bmpImage.Compression);
                                                                                                            System.Console.WriteLine("The number of bits per pixel={0}", bmpImage.BitsPerPixel);
                                                                                                            System.Console.WriteLine("The image dimensions={0} x {1}", bmpImage.Width, bmpImage.Height);
                                                                                                            System.Console.WriteLine("The raw line size={0}", bmpImage.RawLineSize);
                                                                                                            System.Console.WriteLine("The output size in bytes={0}", stream.Length);
                                                                                                        }
                                                                                                    }
                                                                                                }

                                                                                                // The output looks like this:
                                                                                                // ---------------------------------------------
                                                                                                // The compression = Rgb
                                                                                                // The number of bits per pixel = 8
                                                                                                // The image dimensions = 100 x 100
                                                                                                // The raw line size = 100
                                                                                                // The output size in bytes = 11078
                                                                                                // ---------------------------------------------
                                                                                                // The compression = Rle8
                                                                                                // The number of bits per pixel = 8
                                                                                                // The image dimensions = 100 x 100
                                                                                                // The raw line size = 100
                                                                                                // The output size in bytes = 856

FileFormat

이 사용자 친화적 인 속성으로 파일 형식의 가치를 쉽게 얻을 수 있습니다.파일 형식에 대한 정보에 빠른 액세스를 원하는 개발자를위한 이상적입니다.

public override FileFormat FileFormat { get; }

부동산 가치

FileFormat

Examples

다음 예제는 BMP 이미지에서 원료 데이터 형식 및 알파 채널에 대한 정보를 추출하는 방법을 보여줍니다.

// Create a 32-bpp BMP image of 100 x 100 px.
                                                                                                                           using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 32, null))
                                                                                                                           {
                                                                                                                               System.Console.WriteLine("FileFormat={0}, RawDataFormat={1}, HasAlpha={2}", bmpImage.FileFormat, bmpImage.RawDataFormat, bmpImage.HasAlpha);
                                                                                                                           };

                                                                                                                           // Create a 24-bpp BMP image of 100 x 100 px.
                                                                                                                           using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 24, null))
                                                                                                                           {
                                                                                                                               System.Console.WriteLine("FileFormat={0}, RawDataFormat={1}, HasAlpha={2}", bmpImage.FileFormat, bmpImage.RawDataFormat, bmpImage.HasAlpha);
                                                                                                                           };

                                                                                                                           // Generally, BMP doesn't support alpha channel so the output will look like this:
                                                                                                                           // FileFormat = Bmp, RawDataFormat = Rgb32Bpp, used channels: 8,8,8,8, HasAlpha = False
                                                                                                                           // FileFormat = Bmp, RawDataFormat = Rgb24Bpp, used channels: 8,8,8, HasAlpha = False

HasAlpha

이 경우 알파가 있는지 여부를 나타내는 값을 얻습니다.

public override bool HasAlpha { get; }

부동산 가치

bool

Height

이 속성으로 이미지의 높이를 무력하게 회복하십시오. 개발자를위한 이상적인이미지 차원에 대한 정보에 대한 빠른 액세스가 필요합니다.

public override int Height { get; }

부동산 가치

int

Examples

다음 예제는 픽셀 형식, 이미지 크기, 해상도, 압축 등을 포함하여 이미지에 대한 일반적인 정보를 얻습니다.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.bmp"))
                                                                                                                                              {
                                                                                                                                                  Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;                

                                                                                                                                                  System.Console.WriteLine("The pixel format: {0}", bmpImage.RawDataFormat);                
                                                                                                                                                  System.Console.WriteLine("The raw line size in bytes: {0}", bmpImage.RawLineSize);
                                                                                                                                                  System.Console.WriteLine("The bitmap compression: {0}", bmpImage.Compression);
                                                                                                                                                  System.Console.WriteLine("The bitmap width: {0}", bmpImage.Width);
                                                                                                                                                  System.Console.WriteLine("The bitmap height: {0}", bmpImage.Height);
                                                                                                                                                  System.Console.WriteLine("The number of bits per pixel: {0}", bmpImage.BitsPerPixel);

                                                                                                                                                  double hres = bmpImage.HorizontalResolution;
                                                                                                                                                  double vres = bmpImage.VerticalResolution;
                                                                                                                                                  System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", hres);
                                                                                                                                                  System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", vres);

                                                                                                                                                  if (hres != 96.0 || vres != 96.0)
                                                                                                                                                  {
                                                                                                                                                      // You may consider using the SetResolution method for updating both resolution values in single call.
                                                                                                                                                      System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                                                                      bmpImage.SetResolution(96.0, 96.0);

                                                                                                                                                      System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", bmpImage.HorizontalResolution);
                                                                                                                                                      System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", bmpImage.VerticalResolution);
                                                                                                                                                  }

                                                                                                                                                  //The output may look like this:
                                                                                                                                                  //The pixel format: Rgb24Bpp, used channels: 8,8,8
                                                                                                                                                  //The raw line size in bytes: 1500
                                                                                                                                                  //The bitmap compression: Rgb
                                                                                                                                                  //The bitmap width: 500
                                                                                                                                                  //The bitmap height: 375
                                                                                                                                                  //The number of bits per pixel: 24
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 0
                                                                                                                                                  //The vertical resolution, in pixels per inch: 0
                                                                                                                                                  //Set resolution values to 96 dpi
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 96.012
                                                                                                                                                  //The vertical resolution, in pixels per inch: 96.012
                                                                                                                                              }

다음 예제는 bitmap 압축이 출력 이미지 크기에 어떤 영향을 미치는지 보여줍니다.

Aspose.Imaging.FileFormats.Bmp.BitmapCompression[] compressions = new Aspose.Imaging.FileFormats.Bmp.BitmapCompression[]
                                                                                                {
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb,
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rle8,
                                                                                                };

                                                                                                Aspose.Imaging.Color[] paletterColors = new Aspose.Imaging.Color[]
                                                                                                {
                                                                                                    Aspose.Imaging.Color.Red,
                                                                                                    Aspose.Imaging.Color.Green,
                                                                                                };

                                                                                                // Create a monochrome palette which contains only red and green colors.
                                                                                                Aspose.Imaging.IColorPalette palette = new Aspose.Imaging.ColorPalette(paletterColors);

                                                                                                foreach (Aspose.Imaging.FileFormats.Bmp.BitmapCompression compression in compressions)
                                                                                                {
                                                                                                    // Create a 8-bpp BMP image of 100 x 100 px.
                                                                                                    using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 8, palette, compression, 0.0, 0.0))
                                                                                                    {
                                                                                                        Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);

                                                                                                        // Fill the entire image in red.
                                                                                                        Aspose.Imaging.Brushes.SolidBrush redBrush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                                        gr.FillRectangle(redBrush, bmpImage.Bounds);

                                                                                                        // Save the image to a stream to get the output image size.
                                                                                                        using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                        {
                                                                                                            bmpImage.Save(stream);

                                                                                                            System.Console.WriteLine("---------------------------------------------");
                                                                                                            System.Console.WriteLine("The compression={0}", bmpImage.Compression);
                                                                                                            System.Console.WriteLine("The number of bits per pixel={0}", bmpImage.BitsPerPixel);
                                                                                                            System.Console.WriteLine("The image dimensions={0} x {1}", bmpImage.Width, bmpImage.Height);
                                                                                                            System.Console.WriteLine("The raw line size={0}", bmpImage.RawLineSize);
                                                                                                            System.Console.WriteLine("The output size in bytes={0}", stream.Length);
                                                                                                        }
                                                                                                    }
                                                                                                }

                                                                                                // The output looks like this:
                                                                                                // ---------------------------------------------
                                                                                                // The compression = Rgb
                                                                                                // The number of bits per pixel = 8
                                                                                                // The image dimensions = 100 x 100
                                                                                                // The raw line size = 100
                                                                                                // The output size in bytes = 11078
                                                                                                // ---------------------------------------------
                                                                                                // The compression = Rle8
                                                                                                // The number of bits per pixel = 8
                                                                                                // The image dimensions = 100 x 100
                                                                                                // The raw line size = 100
                                                                                                // The output size in bytes = 856

HorizontalResolution

이 숙박 시설은 쉽게 수평 해상도를 얻거나 설정할 수 있습니다.Aspose.Imaging.RasterImage 개체의 인치 당 픽셀로 측정.개발자는 자신의 응용 프로그램에 대한 이미지 해상도에 대한 정확한 통제가 필요합니다.

public override double HorizontalResolution { get; set; }

부동산 가치

double

Examples

다음 예제는 BMP 이미지의 수평 / 수직 해상도를 설정하는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                {
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;

                                                                                                    // Get horizontal and vertical resolution of the BmpImage
                                                                                                    double horizontalResolution = bmpImage.HorizontalResolution;
                                                                                                    double verticalResolution = bmpImage.VerticalResolution;
                                                                                                    System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
                                                                                                    System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);

                                                                                                    if (horizontalResolution != 96.0 || verticalResolution != 96.0)
                                                                                                    {
                                                                                                        // Use the SetResolution method for updating both resolution values in a single call.
                                                                                                        System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                        bmpImage.SetResolution(96.0, 96.0);

                                                                                                        System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", bmpImage.HorizontalResolution);
                                                                                                        System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", bmpImage.VerticalResolution);
                                                                                                    }

                                                                                                    // The output may look like this:
                                                                                                    // The horizontal resolution, in pixels per inch: 0
                                                                                                    // The vertical resolution, in pixels per inch: 0
                                                                                                    // Set resolution values to 96 dpi
                                                                                                    // The horizontal resolution, in pixels per inch: 96.012
                                                                                                    // The vertical resolution, in pixels per inch: 96.012
                                                                                                }

다음 예제는 픽셀 형식, 이미지 크기, 해상도, 압축 등을 포함하여 이미지에 대한 일반적인 정보를 얻습니다.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.bmp"))
                                                                                                                                              {
                                                                                                                                                  Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;                

                                                                                                                                                  System.Console.WriteLine("The pixel format: {0}", bmpImage.RawDataFormat);                
                                                                                                                                                  System.Console.WriteLine("The raw line size in bytes: {0}", bmpImage.RawLineSize);
                                                                                                                                                  System.Console.WriteLine("The bitmap compression: {0}", bmpImage.Compression);
                                                                                                                                                  System.Console.WriteLine("The bitmap width: {0}", bmpImage.Width);
                                                                                                                                                  System.Console.WriteLine("The bitmap height: {0}", bmpImage.Height);
                                                                                                                                                  System.Console.WriteLine("The number of bits per pixel: {0}", bmpImage.BitsPerPixel);

                                                                                                                                                  double hres = bmpImage.HorizontalResolution;
                                                                                                                                                  double vres = bmpImage.VerticalResolution;
                                                                                                                                                  System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", hres);
                                                                                                                                                  System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", vres);

                                                                                                                                                  if (hres != 96.0 || vres != 96.0)
                                                                                                                                                  {
                                                                                                                                                      // You may consider using the SetResolution method for updating both resolution values in single call.
                                                                                                                                                      System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                                                                      bmpImage.SetResolution(96.0, 96.0);

                                                                                                                                                      System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", bmpImage.HorizontalResolution);
                                                                                                                                                      System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", bmpImage.VerticalResolution);
                                                                                                                                                  }

                                                                                                                                                  //The output may look like this:
                                                                                                                                                  //The pixel format: Rgb24Bpp, used channels: 8,8,8
                                                                                                                                                  //The raw line size in bytes: 1500
                                                                                                                                                  //The bitmap compression: Rgb
                                                                                                                                                  //The bitmap width: 500
                                                                                                                                                  //The bitmap height: 375
                                                                                                                                                  //The number of bits per pixel: 24
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 0
                                                                                                                                                  //The vertical resolution, in pixels per inch: 0
                                                                                                                                                  //Set resolution values to 96 dpi
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 96.012
                                                                                                                                                  //The vertical resolution, in pixels per inch: 96.012
                                                                                                                                              }

Remarks

기본적으로 이 값은 항상 96이기 때문에 다른 플랫폼이 스크린 해상도를 반환 할 수 없습니다.SetResolution 방법을 사용하여 하나의 전화에서 두 해상도 값을 업데이트 할 수 있습니다.

RawDataFormat

이 사용자 친화적 인 기능으로 원료 데이터의 형식을 쉽게 얻을 수 있습니다.데이터 형식에 대한 중요한 정보에 빠르게 액세스하려는 개발자를위한 완벽합니다.

public override PixelDataFormat RawDataFormat { get; }

부동산 가치

PixelDataFormat

Examples

다음 예제는 BMP 이미지에서 원료 데이터 형식 및 알파 채널에 대한 정보를 추출하는 방법을 보여줍니다.

// Create a 32-bpp BMP image of 100 x 100 px.
                                                                                                                           using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 32, null))
                                                                                                                           {
                                                                                                                               System.Console.WriteLine("FileFormat={0}, RawDataFormat={1}, HasAlpha={2}", bmpImage.FileFormat, bmpImage.RawDataFormat, bmpImage.HasAlpha);
                                                                                                                           };

                                                                                                                           // Create a 24-bpp BMP image of 100 x 100 px.
                                                                                                                           using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 24, null))
                                                                                                                           {
                                                                                                                               System.Console.WriteLine("FileFormat={0}, RawDataFormat={1}, HasAlpha={2}", bmpImage.FileFormat, bmpImage.RawDataFormat, bmpImage.HasAlpha);
                                                                                                                           };

                                                                                                                           // Generally, BMP doesn't support alpha channel so the output will look like this:
                                                                                                                           // FileFormat = Bmp, RawDataFormat = Rgb32Bpp, used channels: 8,8,8,8, HasAlpha = False
                                                                                                                           // FileFormat = Bmp, RawDataFormat = Rgb24Bpp, used channels: 8,8,8, HasAlpha = False

다음 예제는 픽셀 형식, 이미지 크기, 해상도, 압축 등을 포함하여 이미지에 대한 일반적인 정보를 얻습니다.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.bmp"))
                                                                                                                                              {
                                                                                                                                                  Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;                

                                                                                                                                                  System.Console.WriteLine("The pixel format: {0}", bmpImage.RawDataFormat);                
                                                                                                                                                  System.Console.WriteLine("The raw line size in bytes: {0}", bmpImage.RawLineSize);
                                                                                                                                                  System.Console.WriteLine("The bitmap compression: {0}", bmpImage.Compression);
                                                                                                                                                  System.Console.WriteLine("The bitmap width: {0}", bmpImage.Width);
                                                                                                                                                  System.Console.WriteLine("The bitmap height: {0}", bmpImage.Height);
                                                                                                                                                  System.Console.WriteLine("The number of bits per pixel: {0}", bmpImage.BitsPerPixel);

                                                                                                                                                  double hres = bmpImage.HorizontalResolution;
                                                                                                                                                  double vres = bmpImage.VerticalResolution;
                                                                                                                                                  System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", hres);
                                                                                                                                                  System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", vres);

                                                                                                                                                  if (hres != 96.0 || vres != 96.0)
                                                                                                                                                  {
                                                                                                                                                      // You may consider using the SetResolution method for updating both resolution values in single call.
                                                                                                                                                      System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                                                                      bmpImage.SetResolution(96.0, 96.0);

                                                                                                                                                      System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", bmpImage.HorizontalResolution);
                                                                                                                                                      System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", bmpImage.VerticalResolution);
                                                                                                                                                  }

                                                                                                                                                  //The output may look like this:
                                                                                                                                                  //The pixel format: Rgb24Bpp, used channels: 8,8,8
                                                                                                                                                  //The raw line size in bytes: 1500
                                                                                                                                                  //The bitmap compression: Rgb
                                                                                                                                                  //The bitmap width: 500
                                                                                                                                                  //The bitmap height: 375
                                                                                                                                                  //The number of bits per pixel: 24
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 0
                                                                                                                                                  //The vertical resolution, in pixels per inch: 0
                                                                                                                                                  //Set resolution values to 96 dpi
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 96.012
                                                                                                                                                  //The vertical resolution, in pixels per inch: 96.012
                                                                                                                                              }

RawLineSize

이 간단한 속성으로 각 원료 라인의 크기를 바이트로 빠르게 액세스하십시오.개발자가 원료 이미지 데이터를 효율적으로 처리해야하는 데 이상적입니다.

public override int RawLineSize { get; }

부동산 가치

int

Examples

다음 예제는 픽셀 형식, 이미지 크기, 해상도, 압축 등을 포함하여 이미지에 대한 일반적인 정보를 얻습니다.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.bmp"))
                                                                                                                                              {
                                                                                                                                                  Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;                

                                                                                                                                                  System.Console.WriteLine("The pixel format: {0}", bmpImage.RawDataFormat);                
                                                                                                                                                  System.Console.WriteLine("The raw line size in bytes: {0}", bmpImage.RawLineSize);
                                                                                                                                                  System.Console.WriteLine("The bitmap compression: {0}", bmpImage.Compression);
                                                                                                                                                  System.Console.WriteLine("The bitmap width: {0}", bmpImage.Width);
                                                                                                                                                  System.Console.WriteLine("The bitmap height: {0}", bmpImage.Height);
                                                                                                                                                  System.Console.WriteLine("The number of bits per pixel: {0}", bmpImage.BitsPerPixel);

                                                                                                                                                  double hres = bmpImage.HorizontalResolution;
                                                                                                                                                  double vres = bmpImage.VerticalResolution;
                                                                                                                                                  System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", hres);
                                                                                                                                                  System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", vres);

                                                                                                                                                  if (hres != 96.0 || vres != 96.0)
                                                                                                                                                  {
                                                                                                                                                      // You may consider using the SetResolution method for updating both resolution values in single call.
                                                                                                                                                      System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                                                                      bmpImage.SetResolution(96.0, 96.0);

                                                                                                                                                      System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", bmpImage.HorizontalResolution);
                                                                                                                                                      System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", bmpImage.VerticalResolution);
                                                                                                                                                  }

                                                                                                                                                  //The output may look like this:
                                                                                                                                                  //The pixel format: Rgb24Bpp, used channels: 8,8,8
                                                                                                                                                  //The raw line size in bytes: 1500
                                                                                                                                                  //The bitmap compression: Rgb
                                                                                                                                                  //The bitmap width: 500
                                                                                                                                                  //The bitmap height: 375
                                                                                                                                                  //The number of bits per pixel: 24
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 0
                                                                                                                                                  //The vertical resolution, in pixels per inch: 0
                                                                                                                                                  //Set resolution values to 96 dpi
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 96.012
                                                                                                                                                  //The vertical resolution, in pixels per inch: 96.012
                                                                                                                                              }

다음 예제는 bitmap 압축이 출력 이미지 크기에 어떤 영향을 미치는지 보여줍니다.

Aspose.Imaging.FileFormats.Bmp.BitmapCompression[] compressions = new Aspose.Imaging.FileFormats.Bmp.BitmapCompression[]
                                                                                                {
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb,
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rle8,
                                                                                                };

                                                                                                Aspose.Imaging.Color[] paletterColors = new Aspose.Imaging.Color[]
                                                                                                {
                                                                                                    Aspose.Imaging.Color.Red,
                                                                                                    Aspose.Imaging.Color.Green,
                                                                                                };

                                                                                                // Create a monochrome palette which contains only red and green colors.
                                                                                                Aspose.Imaging.IColorPalette palette = new Aspose.Imaging.ColorPalette(paletterColors);

                                                                                                foreach (Aspose.Imaging.FileFormats.Bmp.BitmapCompression compression in compressions)
                                                                                                {
                                                                                                    // Create a 8-bpp BMP image of 100 x 100 px.
                                                                                                    using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 8, palette, compression, 0.0, 0.0))
                                                                                                    {
                                                                                                        Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);

                                                                                                        // Fill the entire image in red.
                                                                                                        Aspose.Imaging.Brushes.SolidBrush redBrush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                                        gr.FillRectangle(redBrush, bmpImage.Bounds);

                                                                                                        // Save the image to a stream to get the output image size.
                                                                                                        using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                        {
                                                                                                            bmpImage.Save(stream);

                                                                                                            System.Console.WriteLine("---------------------------------------------");
                                                                                                            System.Console.WriteLine("The compression={0}", bmpImage.Compression);
                                                                                                            System.Console.WriteLine("The number of bits per pixel={0}", bmpImage.BitsPerPixel);
                                                                                                            System.Console.WriteLine("The image dimensions={0} x {1}", bmpImage.Width, bmpImage.Height);
                                                                                                            System.Console.WriteLine("The raw line size={0}", bmpImage.RawLineSize);
                                                                                                            System.Console.WriteLine("The output size in bytes={0}", stream.Length);
                                                                                                        }
                                                                                                    }
                                                                                                }

                                                                                                // The output looks like this:
                                                                                                // ---------------------------------------------
                                                                                                // The compression = Rgb
                                                                                                // The number of bits per pixel = 8
                                                                                                // The image dimensions = 100 x 100
                                                                                                // The raw line size = 100
                                                                                                // The output size in bytes = 11078
                                                                                                // ---------------------------------------------
                                                                                                // The compression = Rle8
                                                                                                // The number of bits per pixel = 8
                                                                                                // The image dimensions = 100 x 100
                                                                                                // The raw line size = 100
                                                                                                // The output size in bytes = 856

VerticalResolution

쉽게 수신 또는 수직 해상도를 설정, 인치 당 픽셀으로 측정,이 자산을 가진 Aspose.Imaging.RasterImage 개체.이 원하는 개발자를위한 완벽그들의 응용 프로그램에서 이미지 해상도를 정확하게 제어합니다.

public override double VerticalResolution { get; set; }

부동산 가치

double

Examples

다음 예제는 BMP 이미지의 수평 / 수직 해상도를 설정하는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                {
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;

                                                                                                    // Get horizontal and vertical resolution of the BmpImage
                                                                                                    double horizontalResolution = bmpImage.HorizontalResolution;
                                                                                                    double verticalResolution = bmpImage.VerticalResolution;
                                                                                                    System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
                                                                                                    System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);

                                                                                                    if (horizontalResolution != 96.0 || verticalResolution != 96.0)
                                                                                                    {
                                                                                                        // Use the SetResolution method for updating both resolution values in a single call.
                                                                                                        System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                        bmpImage.SetResolution(96.0, 96.0);

                                                                                                        System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", bmpImage.HorizontalResolution);
                                                                                                        System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", bmpImage.VerticalResolution);
                                                                                                    }

                                                                                                    // The output may look like this:
                                                                                                    // The horizontal resolution, in pixels per inch: 0
                                                                                                    // The vertical resolution, in pixels per inch: 0
                                                                                                    // Set resolution values to 96 dpi
                                                                                                    // The horizontal resolution, in pixels per inch: 96.012
                                                                                                    // The vertical resolution, in pixels per inch: 96.012
                                                                                                }

다음 예제는 픽셀 형식, 이미지 크기, 해상도, 압축 등을 포함하여 이미지에 대한 일반적인 정보를 얻습니다.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.bmp"))
                                                                                                                                              {
                                                                                                                                                  Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;                

                                                                                                                                                  System.Console.WriteLine("The pixel format: {0}", bmpImage.RawDataFormat);                
                                                                                                                                                  System.Console.WriteLine("The raw line size in bytes: {0}", bmpImage.RawLineSize);
                                                                                                                                                  System.Console.WriteLine("The bitmap compression: {0}", bmpImage.Compression);
                                                                                                                                                  System.Console.WriteLine("The bitmap width: {0}", bmpImage.Width);
                                                                                                                                                  System.Console.WriteLine("The bitmap height: {0}", bmpImage.Height);
                                                                                                                                                  System.Console.WriteLine("The number of bits per pixel: {0}", bmpImage.BitsPerPixel);

                                                                                                                                                  double hres = bmpImage.HorizontalResolution;
                                                                                                                                                  double vres = bmpImage.VerticalResolution;
                                                                                                                                                  System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", hres);
                                                                                                                                                  System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", vres);

                                                                                                                                                  if (hres != 96.0 || vres != 96.0)
                                                                                                                                                  {
                                                                                                                                                      // You may consider using the SetResolution method for updating both resolution values in single call.
                                                                                                                                                      System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                                                                      bmpImage.SetResolution(96.0, 96.0);

                                                                                                                                                      System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", bmpImage.HorizontalResolution);
                                                                                                                                                      System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", bmpImage.VerticalResolution);
                                                                                                                                                  }

                                                                                                                                                  //The output may look like this:
                                                                                                                                                  //The pixel format: Rgb24Bpp, used channels: 8,8,8
                                                                                                                                                  //The raw line size in bytes: 1500
                                                                                                                                                  //The bitmap compression: Rgb
                                                                                                                                                  //The bitmap width: 500
                                                                                                                                                  //The bitmap height: 375
                                                                                                                                                  //The number of bits per pixel: 24
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 0
                                                                                                                                                  //The vertical resolution, in pixels per inch: 0
                                                                                                                                                  //Set resolution values to 96 dpi
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 96.012
                                                                                                                                                  //The vertical resolution, in pixels per inch: 96.012
                                                                                                                                              }

Remarks

기본적으로 이 값은 항상 96이기 때문에 다른 플랫폼이 스크린 해상도를 반환 할 수 없습니다.SetResolution 방법을 사용하여 하나의 전화에서 두 해상도 값을 업데이트 할 수 있습니다.

Width

이 속성으로 이미지의 폭에 쉽게 액세스할 수 있습니다. 개발자를위한 이상적인이미지 차원에 대한 빠른 정보를 찾고 있습니다.

public override int Width { get; }

부동산 가치

int

Examples

다음 예제는 픽셀 형식, 이미지 크기, 해상도, 압축 등을 포함하여 이미지에 대한 일반적인 정보를 얻습니다.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.bmp"))
                                                                                                                                              {
                                                                                                                                                  Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;                

                                                                                                                                                  System.Console.WriteLine("The pixel format: {0}", bmpImage.RawDataFormat);                
                                                                                                                                                  System.Console.WriteLine("The raw line size in bytes: {0}", bmpImage.RawLineSize);
                                                                                                                                                  System.Console.WriteLine("The bitmap compression: {0}", bmpImage.Compression);
                                                                                                                                                  System.Console.WriteLine("The bitmap width: {0}", bmpImage.Width);
                                                                                                                                                  System.Console.WriteLine("The bitmap height: {0}", bmpImage.Height);
                                                                                                                                                  System.Console.WriteLine("The number of bits per pixel: {0}", bmpImage.BitsPerPixel);

                                                                                                                                                  double hres = bmpImage.HorizontalResolution;
                                                                                                                                                  double vres = bmpImage.VerticalResolution;
                                                                                                                                                  System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", hres);
                                                                                                                                                  System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", vres);

                                                                                                                                                  if (hres != 96.0 || vres != 96.0)
                                                                                                                                                  {
                                                                                                                                                      // You may consider using the SetResolution method for updating both resolution values in single call.
                                                                                                                                                      System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                                                                      bmpImage.SetResolution(96.0, 96.0);

                                                                                                                                                      System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", bmpImage.HorizontalResolution);
                                                                                                                                                      System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", bmpImage.VerticalResolution);
                                                                                                                                                  }

                                                                                                                                                  //The output may look like this:
                                                                                                                                                  //The pixel format: Rgb24Bpp, used channels: 8,8,8
                                                                                                                                                  //The raw line size in bytes: 1500
                                                                                                                                                  //The bitmap compression: Rgb
                                                                                                                                                  //The bitmap width: 500
                                                                                                                                                  //The bitmap height: 375
                                                                                                                                                  //The number of bits per pixel: 24
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 0
                                                                                                                                                  //The vertical resolution, in pixels per inch: 0
                                                                                                                                                  //Set resolution values to 96 dpi
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 96.012
                                                                                                                                                  //The vertical resolution, in pixels per inch: 96.012
                                                                                                                                              }

다음 예제는 bitmap 압축이 출력 이미지 크기에 어떤 영향을 미치는지 보여줍니다.

Aspose.Imaging.FileFormats.Bmp.BitmapCompression[] compressions = new Aspose.Imaging.FileFormats.Bmp.BitmapCompression[]
                                                                                                {
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb,
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rle8,
                                                                                                };

                                                                                                Aspose.Imaging.Color[] paletterColors = new Aspose.Imaging.Color[]
                                                                                                {
                                                                                                    Aspose.Imaging.Color.Red,
                                                                                                    Aspose.Imaging.Color.Green,
                                                                                                };

                                                                                                // Create a monochrome palette which contains only red and green colors.
                                                                                                Aspose.Imaging.IColorPalette palette = new Aspose.Imaging.ColorPalette(paletterColors);

                                                                                                foreach (Aspose.Imaging.FileFormats.Bmp.BitmapCompression compression in compressions)
                                                                                                {
                                                                                                    // Create a 8-bpp BMP image of 100 x 100 px.
                                                                                                    using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 8, palette, compression, 0.0, 0.0))
                                                                                                    {
                                                                                                        Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);

                                                                                                        // Fill the entire image in red.
                                                                                                        Aspose.Imaging.Brushes.SolidBrush redBrush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                                        gr.FillRectangle(redBrush, bmpImage.Bounds);

                                                                                                        // Save the image to a stream to get the output image size.
                                                                                                        using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                        {
                                                                                                            bmpImage.Save(stream);

                                                                                                            System.Console.WriteLine("---------------------------------------------");
                                                                                                            System.Console.WriteLine("The compression={0}", bmpImage.Compression);
                                                                                                            System.Console.WriteLine("The number of bits per pixel={0}", bmpImage.BitsPerPixel);
                                                                                                            System.Console.WriteLine("The image dimensions={0} x {1}", bmpImage.Width, bmpImage.Height);
                                                                                                            System.Console.WriteLine("The raw line size={0}", bmpImage.RawLineSize);
                                                                                                            System.Console.WriteLine("The output size in bytes={0}", stream.Length);
                                                                                                        }
                                                                                                    }
                                                                                                }

                                                                                                // The output looks like this:
                                                                                                // ---------------------------------------------
                                                                                                // The compression = Rgb
                                                                                                // The number of bits per pixel = 8
                                                                                                // The image dimensions = 100 x 100
                                                                                                // The raw line size = 100
                                                                                                // The output size in bytes = 11078
                                                                                                // ---------------------------------------------
                                                                                                // The compression = Rle8
                                                                                                // The number of bits per pixel = 8
                                                                                                // The image dimensions = 100 x 100
                                                                                                // The raw line size = 100
                                                                                                // The output size in bytes = 856

Methods

GetDefaultOptions(객체[])

이 간단한 방법으로 기본 옵션을 쉽게 복구하십시오.기본 이미지 설정 또는 구성에 빠른 액세스를 원하는 개발자를위한 이상적입니다.

public override ImageOptionsBase GetDefaultOptions(object[] args)

Parameters

args object [ ] [ [ ]

그들의 논쟁들

Returns

ImageOptionsBase

기본 옵션

OnCached()

데이터가 암호화되면 호출되며 관련 모든 자원이 분배될 수 있습니다.

protected override void OnCached()

OnPaletteChanging(아이콜라스, 아이콜라스)

팔레트가 바뀌었을 때 전화를 받았습니다.

protected override void OnPaletteChanging(IColorPalette oldPalette, IColorPalette newPalette)

Parameters

oldPalette IColorPalette

오래된 팔레트

newPalette IColorPalette

새로운 팔레트

SaveData(Stream)

데이터를 저장합니다.

protected override void SaveData(Stream stream)

Parameters

stream Stream

데이터를 저장하기위한 스트림.

SetResolution(더블, 더블)

이와 함께 Aspose.Imaging.RasterImage의 해상도를 쉽게 조정하십시오.사용자 친화적 인 방법. 정확한 통제를 찾는 개발자를위한 완벽한그들의 응용 프로그램에서 이미지 해상도.

public override void SetResolution(double dpiX, double dpiY)

Parameters

dpiX double

Aspose.Imaging.RasterImage의 수평 해상도, 인치 당 포인트.

dpiY double

Aspose.Imaging.RasterImage의 수직 해상도, 인치 당 포인트.

Examples

다음 예제는 BMP 이미지의 수평 / 수직 해상도를 설정하는 방법을 보여줍니다.

string dir = "c:\\temp\\";

                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                {
                                                                                                    Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;

                                                                                                    // Get horizontal and vertical resolution of the BmpImage
                                                                                                    double horizontalResolution = bmpImage.HorizontalResolution;
                                                                                                    double verticalResolution = bmpImage.VerticalResolution;
                                                                                                    System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
                                                                                                    System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);

                                                                                                    if (horizontalResolution != 96.0 || verticalResolution != 96.0)
                                                                                                    {
                                                                                                        // Use the SetResolution method for updating both resolution values in a single call.
                                                                                                        System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                        bmpImage.SetResolution(96.0, 96.0);

                                                                                                        System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", bmpImage.HorizontalResolution);
                                                                                                        System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", bmpImage.VerticalResolution);
                                                                                                    }

                                                                                                    // The output may look like this:
                                                                                                    // The horizontal resolution, in pixels per inch: 0
                                                                                                    // The vertical resolution, in pixels per inch: 0
                                                                                                    // Set resolution values to 96 dpi
                                                                                                    // The horizontal resolution, in pixels per inch: 96.012
                                                                                                    // The vertical resolution, in pixels per inch: 96.012
                                                                                                }

다음 예제는 픽셀 형식, 이미지 크기, 해상도, 압축 등을 포함하여 이미지에 대한 일반적인 정보를 얻습니다.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.bmp"))
                                                                                                                                              {
                                                                                                                                                  Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;                

                                                                                                                                                  System.Console.WriteLine("The pixel format: {0}", bmpImage.RawDataFormat);                
                                                                                                                                                  System.Console.WriteLine("The raw line size in bytes: {0}", bmpImage.RawLineSize);
                                                                                                                                                  System.Console.WriteLine("The bitmap compression: {0}", bmpImage.Compression);
                                                                                                                                                  System.Console.WriteLine("The bitmap width: {0}", bmpImage.Width);
                                                                                                                                                  System.Console.WriteLine("The bitmap height: {0}", bmpImage.Height);
                                                                                                                                                  System.Console.WriteLine("The number of bits per pixel: {0}", bmpImage.BitsPerPixel);

                                                                                                                                                  double hres = bmpImage.HorizontalResolution;
                                                                                                                                                  double vres = bmpImage.VerticalResolution;
                                                                                                                                                  System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", hres);
                                                                                                                                                  System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", vres);

                                                                                                                                                  if (hres != 96.0 || vres != 96.0)
                                                                                                                                                  {
                                                                                                                                                      // You may consider using the SetResolution method for updating both resolution values in single call.
                                                                                                                                                      System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                                                                      bmpImage.SetResolution(96.0, 96.0);

                                                                                                                                                      System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", bmpImage.HorizontalResolution);
                                                                                                                                                      System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", bmpImage.VerticalResolution);
                                                                                                                                                  }

                                                                                                                                                  //The output may look like this:
                                                                                                                                                  //The pixel format: Rgb24Bpp, used channels: 8,8,8
                                                                                                                                                  //The raw line size in bytes: 1500
                                                                                                                                                  //The bitmap compression: Rgb
                                                                                                                                                  //The bitmap width: 500
                                                                                                                                                  //The bitmap height: 375
                                                                                                                                                  //The number of bits per pixel: 24
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 0
                                                                                                                                                  //The vertical resolution, in pixels per inch: 0
                                                                                                                                                  //Set resolution values to 96 dpi
                                                                                                                                                  //The horizontal resolution, in pixels per inch: 96.012
                                                                                                                                                  //The vertical resolution, in pixels per inch: 96.012
                                                                                                                                              }

ToBitmap()

이 간단한 방법으로 라스터 이미지를 비트 맵으로 쉽게 변환합니다.다양한 이미지 형식 사이의 무시무시한 전환을 필요로하는 개발자를위한 완벽합니다.

public override Bitmap ToBitmap()

Returns

Bitmap

비트마프

Examples

다음 예제는 BMP 이미지를 GDI 비트 맵으로 변환합니다.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.bmp"))
                                                                      {
                                                                          Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;
                                                                          System.Drawing.Bitmap bitmap = bmpImage.ToBitmap();

                                                                          // Process the GDI bitmap.
                                                                      }

UpdateDimensions(이트, 이트)

이미지 차원을 업데이트합니다.

protected override void UpdateDimensions(int newWidth, int newHeight)

Parameters

newWidth int

새로운 이미지 폭.

newHeight int

새로운 이미지 높이.

 한국어