Class SrImage
Inheritance
Implements
Inherited Members
Namespace: SaigeVision.Net.V2.Models
Assembly: SaigeVision.Net.V2.dll
Syntax
public class SrImage : IDisposable
Constructors
View SourceSrImage(Bitmap, Uri)
Declaration
public SrImage(Bitmap bitmap, Uri uri = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Bitmap | bitmap | |
| Uri | uri |
SrImage(int, int, int, int, byte[])
Declaration
public SrImage(int width, int height, int stride, int channelSize, byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | |
| int | height | |
| int | stride | |
| int | channelSize | |
| byte[] | data |
SrImage(int, int, int, int, IntPtr)
생성자입니다.
Declaration
public SrImage(int width, int height, int stride, int channelSize, IntPtr data)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | 이미지 가로 길이. |
| int | height | 이미지 세로 길이. |
| int | stride | 직렬화된 데이터의 스트라이드. |
| int | channelSize | 채널 수. |
| IntPtr | data | 데이터 포인트. |
Remarks
width와 height는 지정된 data의 실제 Width, Height가 지정되어야 합니다.
stride는 이미지 데이터를 Matrix 구조로 생각했을때, 하나의 row 가 갖추는 수평 길이입니다.
일반적으로 이미지의 Width * ChannelSize 라고 볼 수 있지만, Width를 알 수 없을때 행의 끝을 알기 위한 Right padding이 주어질 수 있습니다.
이런 경우 Stride는 Width * ChannelSize보다 더 큽니다.
또한 stride가 양수이면 하향식 데이터이며, 음수이면 상향식 데이터입니다.
data는 ChnnelSize가 1일때 Gray scale로 갖추어진 배열 데이터의 포인터를 지정받습니다.
ChannelSize 가 3이라면 BGR 순으로 정렬된 시퀀스 데이터의 포인터를 지정해야합니다.
channelSize는 1,2 일때 GrayScale, 3,6 일때 RGB (8bit, 16bit), 4,8 일때 RGBA (8bit, 16bit) 로 구성되어 있습니다.
해당 생성자의 파라메터에서 가장 주목해야 할 놈은 data입니다.
주입된 data는 사용자에 의해 관리되어야 합니다.
이말은 즉슨, SrImage 인스턴스를 사용하는 동안에 외부에서 data의 메모리를 해제해서는 안됩니다.
생성된 인스턴스의 생명과 관련이 깊음을 의미합니다.
Examples
다음 예제는 System.Drawing.Bitmap을 통해 인스턴스를 생성하여, 파일로 Save 하는 예제로 해당 생성자를 설명합니다.
Bitmap oldImage = new Bitmap(@"c:\Hello.jpg");
Rectangle oldImageBounds = new Rectangle(default, oldImage.Size);
BitmapData oldBitData = oldImage.LockBits(oldImageBounds, ImageLockMode.ReadOnly, oldImage.PixelFormat;
using (SrImage newImage = new SrImage(oldImage.Width, oldImage.Height, oldBitData.Stride, channelSize, oldBitData.Scan0))
{
newImage.Save(@"c:\new_hello.png", ImageFormat.Png);
}
oldImage.UnlockBits(oldBitData);
View Source
SrImage(Stream)
생성자입니다.
Declaration
public SrImage(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | 이미지 데이터를 담은 스트림. |
Remarks
stream은 생성된 인스턴스의 SaigeVision.Net.V2.Models.SrImage.Dispose(System.Boolean)가 호출되지 전까지 연결을 유지해야합니다.
SrImage(string)
생성자입니다.
Declaration
public SrImage(string filePath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filePath | 이미지 파일 경로. |
Examples
가능하다면 아래와 같이 Using 블럭을 사용하세요. SrImage는 System.IDisposable을 상속합니다.
using(SrImage image = new SrImage("c:\Image.jpg"))
{
image.Save("c:\NewImage.jpg", ImageFormat.Jpeg);
}
Properties
View SourceChannel
채널 수 1=8bit grayscale, 2=16bit grayscale, 3=8bit rgb, 4=8bit rgba, 6=16bit rgb, 8=16bit rgba,
Declaration
public int Channel { get; }
Property Value
| Type | Description |
|---|---|
| int |
Height
세로 길이
Declaration
public int Height { get; }
Property Value
| Type | Description |
|---|---|
| int |
PixelFormat
Bitmap Class PixelFormat
Declaration
public PixelFormat PixelFormat { get; }
Property Value
| Type | Description |
|---|---|
| PixelFormat |
Uri
원본 이미지의 Uri
Declaration
public Uri Uri { get; }
Property Value
| Type | Description |
|---|---|
| Uri |
Remarks
File path를 통한 생성자를 통해 생성된 인스턴스만 값을 가질 수 있으며, 그외 생성자는 해당 값을 null로 표현합니다.
Width
가로 길이
Declaration
public int Width { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
View SourceDispose()
Declaration
public void Dispose()
~SrImage()
Declaration
protected ~SrImage()
Save(Stream, ImageFormat)
이미지를 저장합니다.
Declaration
public void Save(Stream stream, ImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | 저장할 스트림. |
| ImageFormat | format | 저장에 사용할 이미지 포맷. |
Save(string, ImageFormat)
이미지를 저장합니다.
Declaration
public void Save(string path, ImageFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | 저장할 파일 경로. |
| ImageFormat | format | 저장에 사용할 이미지 포맷. |
ToBitmap()
Declaration
public Bitmap ToBitmap()
Returns
| Type | Description |
|---|---|
| Bitmap |
Operators
View Sourceimplicit operator Bitmap(SrImage)
Declaration
public static implicit operator Bitmap(SrImage image)
Parameters
| Type | Name | Description |
|---|---|---|
| SrImage | image |
Returns
| Type | Description |
|---|---|
| Bitmap |