IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
PixelFormatConversionModule.cs
Go to the documentation of this file.
5
7
21public class PixelFormatConversionModule : ModuleBase, IDisposable
22{
27
28 internal const string OutputPixelFormatKey = "OutputPixelFormat";
29 private readonly ImageConverterCInterface.Handle _handle;
30
35 {
36 var handle = new ImageConverterCInterface.Handle();
37 DllHelper.ExecuteAndMapReturnCodes(() =>
38 ImageConverterCInterface.CInterface.peak_icv_Preprocessing_ImageConverter_Create(out handle));
39 _handle = handle;
40 }
41
43 public override string TypeId => "PixelFormatConversion";
44
49
53 public void Dispose()
54 {
55 _handle.Dispose();
56 GC.SuppressFinalize(this);
57 }
58
72 public override Image Process(Image inputImage)
73 {
74 if (!IsEnabled)
75 {
76 return inputImage;
77 }
78
79 PixelFormat inputFormat = inputImage.PixelFormat;
80
81 if (inputFormat == OutputPixelFormat)
82 {
83 return inputImage;
84 }
85
86 var outputImageHandle = new Image.Handle();
87
88 DllHelper.ExecuteAndMapReturnCodes(() =>
89 ImageConverterCInterface.CInterface.peak_icv_Preprocessing_ImageConverter_Convert(_handle,
90 inputImage._handle,
91 OutputPixelFormat, out outputImageHandle));
92
93 return new Image(outputImageHandle);
94 }
95
112 public void ReleaseBuffers()
113 {
114 DllHelper.ExecuteAndMapReturnCodes(() =>
115 ImageConverterCInterface.CInterface.peak_icv_Preprocessing_ImageConverter_ReleaseBuffers(_handle));
116 }
117
126 public override void ResetToDefault()
127 {
129 }
130
142 public override void Serialize(IArchive archive)
143 {
144 base.Serialize(archive);
145 archive.SetString(OutputPixelFormatKey, new PixelFormatInfo(OutputPixelFormat).Name);
146 }
147
172 public override void Deserialize(IArchive archive)
173 {
174 base.Deserialize(archive);
175 OutputPixelFormat = new PixelFormatInfo(archive.GetString(OutputPixelFormatKey)).PixelFormat;
176 }
177}
Provides information and utility functions for pixel formats. The PixelFormatInfo class offers method...
PixelFormat PixelFormat
The underlying pixel format enumeration value.
Base class for all pipeline modules.
Definition ModuleBase.cs:13
virtual bool IsEnabled
Get whether this module is enabled.
Definition ModuleBase.cs:28
Pixel format conversion module that transforms images to a specified output pixel format.
override void Deserialize(IArchive archive)
Restores the object's state from the provided archive.
override Image Process(Image inputImage)
Converts the input image to the configured output pixel format.
PixelFormatConversionModule()
Creates an instance of class PixelFormatConversionModule.
override void ResetToDefault()
Resets the output pixel format to its default value ( PixelFormat.RGB8).
const PixelFormat DefaultOutputPixelFormat
The default output pixel format.
override string TypeId
The unique type identifier for this module implementation.This should be a unique string identifying ...
override void Serialize(IArchive archive)
Serializes the object's internal state into the provided archive.
Constructs an Image from an IImageView Instance.
Definition Image.cs:18
PixelFormat PixelFormat
Gets the pixel format from the image.
Definition Image.cs:217
PixelFormat
Each enumerator represents a specific pixel layout and bit-depth, used for interpreting raw image dat...
Represents a hierarchical, strongly-typed key-value archive.
Definition IArchive.cs:79
string GetString(string key)
Retrieves a string value by key.
void SetString(string key, string value)
Stores a string value under the specified key.