OverlayCommand Class |
Namespace: Atalasoft.Imaging.ImageProcessing
The OverlayCommand type exposes the following members.
Name | Description | |
---|---|---|
OverlayCommand |
Initializes a new instance of the OverlayCommand class.
| |
OverlayCommand(SerializationInfo, StreamingContext) | Initializes a new instance of %OverlayCommand%. | |
OverlayCommand(AtalaImage, Point) |
Overlay one image onto another.
| |
OverlayCommand(AtalaImage, Point, Double) |
Overlay one image onto another.
| |
OverlayCommand(AtalaImage, Point, Color) |
Overlay one image onto another.
| |
OverlayCommand(AtalaImage, Point, Int32) |
Overlay an 8-bit image onto another.
|
Name | Description | |
---|---|---|
ApplyToAnyPixelFormat | Reports whether or not this command will be applied to any supplied PixelFormat image (Inherited from ImageCommand.) | |
CanApplyToAnyPixelFormat | Returns true if the command can be applied to any PixelFormat. (Inherited from ImageCommand.) | |
InPlaceProcessing | Gets a value indicating whether the command returns a new image or modified the source image passed into
the command. (Overrides ImageCommandInPlaceProcessing.) | |
Opacity | Gets or sets the opacity of the top image. | |
Position | Gets or sets the position of the top image with respect to the source image. | |
Progress | Gets or sets the ProgressEventHandler delegate which can be used to view or cancel the
progress of the current process. (Inherited from ImageCommand.) | |
SupportedPixelFormats | Returns an array of PixelFormats supported by this command. (Overrides ImageCommandSupportedPixelFormats.) | |
TopImage | Gets or sets the image that will be overlayed onto the source image. | |
TransparentColor | Gets or sets the color that will be used as a transparent mask for the top image. | |
TransparentIndex | Gets or sets the palette index that will be used as a transparent mask for the top image. |
Name | Description | |
---|---|---|
Apply | Apply the command to the given image. (Inherited from ImageCommand.) | |
ApplyToImage | Obsolete.
Applies the command to the source AtalaImage.
(Inherited from ImageCommand.) | |
ConstructChangedSourceImage | The method is called by the default implementation of Apply. It determines if it is necessary to create a
copy of the source image in a different pixel format and if so, determines the best new pixel format and allocates
that image. (Inherited from ImageCommand.) | |
ConstructFinalImage | Called by the default implementation of Apply, ConstructFinalImage constructs the image that will be used
as the destination image for the command. (Inherited from ImageCommand.) | |
ConstructImageResults | Constructs the results object for this command. (Inherited from ImageCommand.) | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetChangedPixelFormat | This method is called to change the pixel format of the source image. (Inherited from ImageCommand.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetObjectData |
Populates a SerializationInfo with the data needed to serialize the target object.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ImageCommandGetObjectData | Aggregates ImageCommand data into the supplied SerializationInfo object. (Inherited from ImageCommand.) | |
IsPixelFormatSupported | Returns a value indicating if the specified pixel format is supported. (Inherited from ImageCommand.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
PerformActualCommand |
Performs the actual command.
(Overrides ImageCommandPerformActualCommand(AtalaImage, AtalaImage, Rectangle, ImageResults).) | |
SelectBestAlternatePixelFormat | Choose the best pixel format to use for this command when the supplied source image's pixel format is
unacceptable. (Inherited from ImageCommand.) | |
SelectPreferredPixelFormat | Chooses a pixel format that is preferred for this command. (Inherited from ImageCommand.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
VerifyImage | Verify the integrity of an AtalaImage. (Inherited from ImageCommand.) | |
VerifyProperties |
Verifies the properties.
(Overrides ImageCommandVerifyProperties(AtalaImage).) |
If the top image has an alpha channel, that alpha will be used to control the transparency of the overlay and will override the %TransparentColor% and %Opacity% values.
When overlaying one image with alpha, on top of another image with alpha, the alpha channels will be merged to take the maximum pixel value of each alpha channel. See OverlayMergedCommand for more specific options.
The top image will always be converted to the pixel format of the bottom image, unless the top image has an alpha channel, which it will then use for alpha blending.
This command supports all pixel formats with the exception of 4-bit Indexed.
This command processes the source image in-place, and ApplyToImage always returns null.
private AtalaImage OverlayImage(string bottomFile, string topFile, Point position) { // Make sure the files exist. if (!File.Exists(bottomFile)) throw new FileNotFoundException("The bottom image file could not be found.", bottomFile); if (!File.Exists(topFile)) throw new FileNotFoundException("The file to overlay could not be found.", topFile); // Load the bottom image. AtalaImage tmpImage = new AtalaImage(bottomFile); // Overlay does not support 4-bit bottom images. AtalaImage bottomImage = null; if (tmpImage.PixelFormat == PixelFormat.Pixel4bppIndexed) { bottomImage = tmpImage.GetChangedPixelFormat(PixelFormat.Pixel8bppIndexed); tmpImage.Dispose(); } else bottomImage = tmpImage; // Load the top image. tmpImage = new AtalaImage(topFile); // If the bottom image is 16-bit per component, the top image must be the same. AtalaImage topImage = null; if (AtalaImage.PixelFormatIsTwoBytePerComponent(bottomImage.PixelFormat) && topImage.PixelFormat != bottomImage.PixelFormat) { topImage = tmpImage.GetChangedPixelFormat(bottomImage.PixelFormat); tmpImage.Dispose(); } else topImage = tmpImage; OverlayCommand cmd = new OverlayCommand(topImage, position); cmd.ApplyToImage(bottomImage); // We are done with the top image. topImage.Dispose(); return bottomImage; }
Private Function OverlayImage(ByVal bottomFile As String, ByVal topFile As String, ByVal position As Point) As AtalaImage ' Make sure the files exist. If Not File.Exists(bottomFile) Then Throw New FileNotFoundException("The bottom image file could not be found.", bottomFile) End If If Not File.Exists(topFile) Then Throw New FileNotFoundException("The file to overlay could not be found.", topFile) End If ' Load the bottom image. Dim tmpImage As AtalaImage = New AtalaImage(bottomFile) ' Overlay does not support 4-bit bottom images. Dim bottomImage As AtalaImage = Nothing If tmpImage.PixelFormat = PixelFormat.Pixel4bppIndexed Then bottomImage = tmpImage.GetChangedPixelFormat(PixelFormat.Pixel8bppIndexed) tmpImage.Dispose() Else bottomImage = tmpImage End If ' Load the top image. tmpImage = New AtalaImage(topFile) ' If the bottom image is 16-bit per component, the top image must be the same. Dim topImage As AtalaImage = Nothing If AtalaImage.PixelFormatIsTwoBytePerComponent(bottomImage.PixelFormat) And topImage.PixelFormat <> bottomImage.PixelFormat Then topImage = tmpImage.GetChangedPixelFormat(bottomImage.PixelFormat) tmpImage.Dispose() Else topImage = tmpImage End If Dim cmd As OverlayCommand = New OverlayCommand(topImage,position) cmd.ApplyToImage(bottomImage) ' We are done with the top image. topImage.Dispose() Return bottomImage End Function