Error processing SSI file
LEADTOOLS (Leadtools assembly)

Show in webframe

GetOverlayImage Method








The index of the overlay being retrieved. This index is zero-based and should be less or equal than MaxOverlays.
Determines how to retreive the image, possible values are:
Mode Description
RasterGetSetOverlayImageMode.Copy A copy of the overlay image is retrieved from the overlay list.
RasterGetSetOverlayImageMode.NoCopy The actual overlay image is retrieved. No copy is made. You should be careful when modifying the returned overlay image because you can modify/invalidate the entry in the overlay bitmap list.
RasterGetSetOverlayImageMode.Move The actual overlay image is retrieved. The image is also removed from the overlay list. This is recommended over RasterGetSetOverlayImageMode.NoCopy.
Gets the overlay image for the specified index.
Syntax
'Declaration
 
Public Function GetOverlayImage( _
   ByVal index As Integer, _
   ByVal mode As RasterGetSetOverlayImageMode _
) As RasterImage
'Usage
 
Dim instance As RasterImage
Dim index As Integer
Dim mode As RasterGetSetOverlayImageMode
Dim value As RasterImage
 
value = instance.GetOverlayImage(index, mode)
- (nullable LTRasterImage *)getOverlayForImageAtIndex:(NSInteger)index 
                                                 mode:(LTRasterGetSetOverlayImageMode)mode 
                                                error:(NSError **)error
            
public RasterImage getOverlayImage(
  int index, 
  RasterGetSetOverlayImageMode mode
)
            
 function Leadtools.RasterImage.GetOverlayImage( 
   index ,
   mode 
)

Parameters

index
The index of the overlay being retrieved. This index is zero-based and should be less or equal than MaxOverlays.
mode
Determines how to retreive the image, possible values are:
Mode Description
RasterGetSetOverlayImageMode.Copy A copy of the overlay image is retrieved from the overlay list.
RasterGetSetOverlayImageMode.NoCopy The actual overlay image is retrieved. No copy is made. You should be careful when modifying the returned overlay image because you can modify/invalidate the entry in the overlay bitmap list.
RasterGetSetOverlayImageMode.Move The actual overlay image is retrieved. The image is also removed from the overlay list. This is recommended over RasterGetSetOverlayImageMode.NoCopy.

Return Value

A RasterImage object that represents the overlay image of the specified index.
Remarks

This method is available in the (Document/Medical only) Toolkits.

This method can be used to get a copy of the overlay image (RasterGetSetOverlayImageMode.Copy) or to get the image without making a copy (RasterGetSetOverlayImageMode.NoCopy or RasterGetSetOverlayImageMode.Move).

The quickest way to get the overlay image is to avoid making a copy. For more information on using RasterGetSetOverlayImageMode.NoCopy, refer to the "Remarks" section of SetOverlayImage.

For more information, refer to Overlay Overview.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Controls
Imports Leadtools.Dicom
Imports Leadtools.Drawing
Imports Leadtools.Svg

      
Public Sub GetOverlayImageExample()
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' load an image and set an overlay
   Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE2.DCM"), 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)
   Dim imageOverlay1 As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ULAY1.BMP"), 1, CodecsLoadByteOrder.Rgb, 1, 1)
   Dim imageOverlay2 As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ULAY1.BMP"), 1, CodecsLoadByteOrder.Rgb, 1, 1)
   image.SetOverlayImage(0, imageOverlay1, RasterGetSetOverlayImageMode.Copy)
   image.SetOverlayImage(1, imageOverlay2, RasterGetSetOverlayImageMode.Copy)
   ' update the attributes of one of the overlays
   Dim attributes As RasterOverlayAttributes = image.GetOverlayAttributes( _
      0, RasterGetSetOverlayAttributesFlags.Color Or RasterGetSetOverlayAttributesFlags.Flags Or _
      RasterGetSetOverlayAttributesFlags.Origin Or RasterGetSetOverlayAttributesFlags.BitIndex)

   attributes.Color = New RasterColor(255, 255, 255)
   attributes.AutoPaint = True
   attributes.AutoProcess = True
   attributes.Origin = New LeadPoint(5, 5)
   attributes.BitPosition = image.BitsPerPixel - 1

   image.UpdateOverlayAttributes(0, attributes, RasterGetSetOverlayAttributesFlags.Color Or _
                                 RasterGetSetOverlayAttributesFlags.Flags Or RasterGetSetOverlayAttributesFlags.Origin Or _
                                 RasterGetSetOverlayAttributesFlags.BitIndex)


   Dim count As Integer = image.OverlayCount
   Dim i As Integer = 0
   Do While i < count
      Dim overlayTest As RasterImage = image.GetOverlayImage(i, RasterGetSetOverlayImageMode.NoCopy)
      Try
         Dim fileName As String = String.Format(Path.Combine(LEAD_VARS.ImagesDir, "overlay{0}_copy.bmp"), i)
         codecs.Save(overlayTest, fileName, RasterImageFormat.Bmp, 1)
      Finally
         CType(overlayTest, IDisposable).Dispose()
      End Try
      i += 1
   Loop

   image.Dispose()
   imageOverlay1.Dispose()
   imageOverlay2.Dispose()
   codecs.Dispose()
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;
using Leadtools.Drawing;
using Leadtools.Controls;
using Leadtools.Svg;

      
public void GetOverlayImageExample()
{
   RasterCodecs codecs = new RasterCodecs();
   // load an image and set an overlay
   RasterImage image = codecs.Load(Path.Combine(ImagesPath.Path, "IMAGE2.DCM"), 0, CodecsLoadByteOrder.BgrOrGray, 1, 1);
   RasterImage imageOverlay1 = codecs.Load(Path.Combine(ImagesPath.Path, "ULAY1.BMP"), 1, CodecsLoadByteOrder.Rgb, 1, 1);
   RasterImage imageOverlay2 = codecs.Load(Path.Combine(ImagesPath.Path, "ULAY1.BMP"), 1, CodecsLoadByteOrder.Rgb, 1, 1);
   image.SetOverlayImage(0, imageOverlay1, RasterGetSetOverlayImageMode.Copy);
   image.SetOverlayImage(1, imageOverlay2, RasterGetSetOverlayImageMode.Copy);
   // update the attributes of one of the overlays
   RasterOverlayAttributes attributes = image.GetOverlayAttributes(0,
      RasterGetSetOverlayAttributesFlags.Color |
      RasterGetSetOverlayAttributesFlags.Flags |
      RasterGetSetOverlayAttributesFlags.Origin |
      RasterGetSetOverlayAttributesFlags.BitIndex);

   attributes.Color = new RasterColor(255, 255, 255);
   attributes.AutoPaint = true;
   attributes.AutoProcess = true;
   attributes.Origin = new LeadPoint(5, 5);
   attributes.BitPosition = image.BitsPerPixel - 1;

   image.UpdateOverlayAttributes(
      0,
      attributes,
      RasterGetSetOverlayAttributesFlags.Color |
      RasterGetSetOverlayAttributesFlags.Flags |
      RasterGetSetOverlayAttributesFlags.Origin |
      RasterGetSetOverlayAttributesFlags.BitIndex);


   int count = image.OverlayCount;
   for(int i = 0; i < count; i++)
   {
      using(RasterImage overlayTest = image.GetOverlayImage(i, RasterGetSetOverlayImageMode.NoCopy))
      {               
         string fileName = string.Format(Path.Combine(ImagesPath.Path,"overlay{0}_copy.bmp"), i);
         codecs.Save(overlayTest, fileName, RasterImageFormat.Bmp, 1);
      }
   }

   image.Dispose();
   imageOverlay1.Dispose();
   imageOverlay2.Dispose();
   codecs.Dispose();
}
RasterImageExamples.prototype.GetOverlayImageExample = function ( ) 
{
   Tools.SetLicense ( ) ;
   with ( Leadtools ) 
   {
      with (Leadtools.Codecs) {

         var codecs = new RasterCodecs();
         // load an image and set an overlay
         var srcFileName = "Assets\\image2.dcm";
         var srcFileName2 = "Assets\\ULAY1.BMP";
         var image;
         var imageOverlay1;
         var imageOverlay2;
         var overlayTest;
         return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
            return codecs.loadAsync(LeadStreamFactory.create(loadFile), 16, CodecsLoadByteOrder.bgrOrGray, 1, 1)
         })
            .then(function (img) {
               image = img;

               
               return Tools.AppInstallFolder().getFileAsync(srcFileName2)
            })
            .then(function (loadFile2) {
               return codecs.loadAsync(LeadStreamFactory.create(loadFile2), 1, CodecsLoadByteOrder.bgr, 1, 1)
            })
            .then(function (imgOver1) {
               imageOverlay1 = imgOver1;

               return Tools.AppInstallFolder().getFileAsync(srcFileName2)
            })
            .then(function (loadFile3) {
               return codecs.loadAsync(LeadStreamFactory.create(loadFile3), 1, CodecsLoadByteOrder.bgr, 1, 1)
            })
            .then(function (imgOver2) {
               imageOverlay2 = imgOver2;

               image.setOverlayImage(0, imageOverlay1, RasterGetSetOverlayImageMode.copy);
               image.setOverlayImage(1, imageOverlay2, RasterGetSetOverlayImageMode.copy);

               // update the attributes of one of the overlays
               var attributes = image.getOverlayAttributes(0,
                  RasterGetSetOverlayAttributesFlags.color |
                  RasterGetSetOverlayAttributesFlags.flags |
                  RasterGetSetOverlayAttributesFlags.origin |
                  RasterGetSetOverlayAttributesFlags.bitIndex);

               attributes.color = RasterColorHelper.create(255, 255, 255);
               attributes.autoPaint = true;
               attributes.autoProcess = true;
               attributes.origin = LeadPointHelper.create(5, 5);
               attributes.bitPosition = image.bitsPerPixel - 1;

               image.updateOverlayAttributes(
                  0,
                  attributes,
                  RasterGetSetOverlayAttributesFlags.color |
                  RasterGetSetOverlayAttributesFlags.flags |
                  RasterGetSetOverlayAttributesFlags.origin |
                  RasterGetSetOverlayAttributesFlags.bitIndex);


               var count = image.overlayCount;
               for (var i = 0; i < count; i++) {
                  overlayTest = image.getOverlayImage(i, RasterGetSetOverlayImageMode.noCopy)

                  Tools.AppLocalFolder().createFileAsync("overlay" + i + "_copy.bmp").then(function (saveFile) {

                     var saveStream = LeadStreamFactory.create(saveFile);
                     codecs.saveAsync(overlayTest, saveStream, RasterImageFormat.bmp, 1);
                  }).then(function () {
                     overlayTest.close();
                  });
               }

               image.close();
               imageOverlay1.close();
               imageOverlay2.close();
               codecs.close();
            });
      }
   }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;

      
public async Task GetOverlayImageExample()
{
   RasterCodecs codecs = new RasterCodecs();
   // load an image and set an overlay
   string srcFileName = @"Assets\image2.dcm";
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile), 16, CodecsLoadByteOrder.BgrOrGray, 1, 1);
   string srcFileName2 = @"Assets\ULAY1.BMP";
   StorageFile loadFile2 = await Tools.AppInstallFolder.GetFileAsync(srcFileName2);
   RasterImage imageOverlay1 = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile2), 1, CodecsLoadByteOrder.Bgr, 1, 1);
   StorageFile loadFile3 = await Tools.AppInstallFolder.GetFileAsync(srcFileName2);
   RasterImage imageOverlay2 = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile3), 1, CodecsLoadByteOrder.Bgr, 1, 1);

   image.SetOverlayImage(0, imageOverlay1, RasterGetSetOverlayImageMode.Copy);
   image.SetOverlayImage(1, imageOverlay2, RasterGetSetOverlayImageMode.Copy);

   // update the attributes of one of the overlays
   RasterOverlayAttributes attributes = image.GetOverlayAttributes(0,
      RasterGetSetOverlayAttributesFlags.Color |
      RasterGetSetOverlayAttributesFlags.Flags |
      RasterGetSetOverlayAttributesFlags.Origin |
      RasterGetSetOverlayAttributesFlags.BitIndex);

   attributes.Color = RasterColorHelper.Create(255, 255, 255);
   attributes.AutoPaint = true;
   attributes.AutoProcess = true;
   attributes.Origin = LeadPointHelper.Create(5, 5);
   attributes.BitPosition = image.BitsPerPixel - 1;

   image.UpdateOverlayAttributes(
      0,
      attributes,
      RasterGetSetOverlayAttributesFlags.Color |
      RasterGetSetOverlayAttributesFlags.Flags |
      RasterGetSetOverlayAttributesFlags.Origin |
      RasterGetSetOverlayAttributesFlags.BitIndex);


   int count = image.OverlayCount;
   for (int i = 0; i < count; i++)
   {
      using (RasterImage overlayTest = image.GetOverlayImage(i, RasterGetSetOverlayImageMode.NoCopy))
      {
         StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(string.Format("overlay{0}_copy.bmp", i));
         ILeadStream saveStream = LeadStreamFactory.Create(saveFile);
         await codecs.SaveAsync(overlayTest, saveStream, RasterImageFormat.Bmp, 1);
      }
   }

   image.Dispose();
   imageOverlay1.Dispose();
   imageOverlay2.Dispose();
   codecs.Dispose();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Dicom;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Examples;
using Leadtools.Windows.Media;

public void GetOverlayImageExample(RasterImage image, RasterImage imageOverlay1, RasterImage imageOverlay2, Stream destStream1, Stream destStream2)
{
   // for this sample:
   //  image         == 24-bit image (image1.cmp)
   //  imageOverlay1 == 1-bit image (ulay1.bmp)
   //  imageOverlay2 == 1-bit image (ulay2.bmp)
   image.SetOverlayImage(0, imageOverlay1, RasterGetSetOverlayImageMode.Copy);
   image.SetOverlayImage(1, imageOverlay2, RasterGetSetOverlayImageMode.Copy);
   // update the attributes of one of the overlays
   RasterOverlayAttributes attributes = image.GetOverlayAttributes(0,
      RasterGetSetOverlayAttributesFlags.Color |
      RasterGetSetOverlayAttributesFlags.Flags |
      RasterGetSetOverlayAttributesFlags.Origin |
      RasterGetSetOverlayAttributesFlags.BitIndex);

   attributes.Color = new RasterColor(255, 255, 255);
   attributes.AutoPaint = true;
   attributes.AutoProcess = true;
   attributes.Origin = new LeadPoint(5, 5);
   attributes.BitPosition = image.BitsPerPixel - 1;

   image.UpdateOverlayAttributes(
      0,
      attributes,
      RasterGetSetOverlayAttributesFlags.Color |
      RasterGetSetOverlayAttributesFlags.Flags |
      RasterGetSetOverlayAttributesFlags.Origin |
      RasterGetSetOverlayAttributesFlags.BitIndex);

   RasterCodecs codecs = new RasterCodecs();
   int count = image.OverlayCount;
   Debug.Assert(count == 2);

   RasterImage overlayTest = image.GetOverlayImage(0, RasterGetSetOverlayImageMode.NoCopy);
   codecs.Save(overlayTest, destStream1, RasterImageFormat.Png, 1);
   overlayTest = image.GetOverlayImage(0, RasterGetSetOverlayImageMode.NoCopy);
   codecs.Save(overlayTest, destStream2, RasterImageFormat.Png, 1);

   image.Dispose();
   overlayTest.Dispose();
   imageOverlay1.Dispose();
   imageOverlay2.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Dicom
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Windows.Media

Public Sub GetOverlayImageExample(ByVal image As RasterImage, ByVal imageOverlay1 As RasterImage, ByVal imageOverlay2 As RasterImage, ByVal destStream1 As Stream, ByVal destStream2 As Stream)
   ' for this sample:
   '  image         == 24-bit image (image1.cmp)
   '  imageOverlay1 == 1-bit image (ulay1.bmp)
   '  imageOverlay2 == 1-bit image (ulay2.bmp)
   image.SetOverlayImage(0, imageOverlay1, RasterGetSetOverlayImageMode.Copy)
   image.SetOverlayImage(1, imageOverlay2, RasterGetSetOverlayImageMode.Copy)
   ' update the attributes of one of the overlays
   Dim attributes As RasterOverlayAttributes = image.GetOverlayAttributes(0, RasterGetSetOverlayAttributesFlags.Color Or RasterGetSetOverlayAttributesFlags.Flags Or RasterGetSetOverlayAttributesFlags.Origin Or _
      RasterGetSetOverlayAttributesFlags.BitIndex)

   attributes.Color = New RasterColor(255, 255, 255)
   attributes.AutoPaint = True
   attributes.AutoProcess = True
   attributes.Origin = New LeadPoint(5, 5)
   attributes.BitPosition = image.BitsPerPixel - 1

   image.UpdateOverlayAttributes(0, attributes, RasterGetSetOverlayAttributesFlags.Color Or RasterGetSetOverlayAttributesFlags.Flags Or RasterGetSetOverlayAttributesFlags.Origin Or RasterGetSetOverlayAttributesFlags.BitIndex)

   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim count As Integer = image.OverlayCount
   Debug.Assert(count = 2)

   Dim overlayTest As RasterImage = image.GetOverlayImage(0, RasterGetSetOverlayImageMode.NoCopy)
   codecs.Save(overlayTest, destStream1, RasterImageFormat.Png, 1)
   overlayTest = image.GetOverlayImage(0, RasterGetSetOverlayImageMode.NoCopy)
   codecs.Save(overlayTest, destStream2, RasterImageFormat.Png, 1)

   image.Dispose()
   overlayTest.Dispose()
   imageOverlay1.Dispose()
   imageOverlay2.Dispose()
End Sub
Requirements

Target Platforms

See Also

Reference

RasterImage Class
RasterImage Members

Error processing SSI file