LEADTOOLS(Leadtoolsアセンブリ)

フレームを表示

Markersプロパティ








特定のファイルフォーマット(JPEGを含む)を読み書きする際に使われるマーカーデータのコレクション。
構文
public IVector<RasterMarkerMetadata> Markers {get;}
'Declaration
 
Public ReadOnly Property Markers As IVector(Of RasterMarkerMetadata)
'Usage
 
Dim instance As RasterImage
Dim value As IVector(Of RasterMarkerMetadata)
 
value = instance.Markers
public IVector<RasterMarkerMetadata> Markers {get;}
 get_Markers(); 
public:
property IVector<RasterMarkerMetadata^>^ Markers {
   IVector<RasterMarkerMetadata^>^ get();
}

属性値

特定のファイルフォーマット(JPEGを含む)を読み書きするとき、使われるRasterMarkerMetadataのコレクション。
解説

いくつかの形式は、非画像データ(例えばコメント、タグとマーカー)を保存することができます。

このコレクションにRasterMarkerMetadataオブジェクトを追加または削除することによって、imageのマーカーを操作することができます。

RasterCodecs.Saveを呼び出す前にCodecsSaveOptions.Markersプロパティをtrueに設定することによって、imageがファイルに保存されるとき、このコレクションでマーカーを保存することができます。

RasterCodecs.Loadを呼び出す前にCodecsLoadOptions.Markersプロパティをtrueに設定することによって、imageがファイルからロードされるとき、すべてのマーカー(任意であるならば)をこのコレクションへロードすることができます。

マーカーを保存する既存ファイルとRasterCodecs.WriteMarkersメソッドから既存ファイルまで直接マーカーをロードするために、RasterCodecs.ReadMarkersメソッドを使うことができます。

詳細については、「非画像データ」を参照してください。

サンプル
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 MarkersExample()
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP"))
   Dim byteData As Byte() = New Byte(0) {}
   byteData(0) = 40
   ' write APP5 (since nobody writes that)
   Dim markerData As RasterMarkerMetadata = New RasterMarkerMetadata(RasterMarkerMetadata.App0 + 5, byteData)
   image.Markers.Add(markerData)

   codecs.Options.Save.Markers = True
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_MARKERS.JPG"), RasterImageFormat.Jpeg, 0)

   ' load the marker together with the image
   Dim marker As RasterCollection(Of RasterMarkerMetadata) = codecs.ReadMarkers(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_MARKERS.JPG"))
   ' look for the APP5 marker, because there might be other markers (like APP0, APP1)
   For Each markerItem As RasterMarkerMetadata In marker
      If markerItem.Id = RasterMarkerMetadata.App0 + 5 Then
         MessageBox.Show("marker Id :" & markerItem.Id.ToString() & " = " & markerItem.GetData().ToString())
      End If
   Next markerItem

   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 MarkersExample()
{
   RasterCodecs codecs = new RasterCodecs();
   RasterImage image = codecs.Load(Path.Combine(ImagesPath.Path,"IMAGE1.CMP"));
   byte[] byteData = new byte[1];
   byteData[0] = 40;
   // write APP5 (since nobody writes that)
   RasterMarkerMetadata markerData = new RasterMarkerMetadata(RasterMarkerMetadata.App0 + 5, byteData);
   image.Markers.Add(markerData);

   codecs.Options.Save.Markers = true;
   codecs.Save(image, Path.Combine(ImagesPath.Path, "IMAGE1_MARKERS.JPG"), RasterImageFormat.Jpeg, 0);

   // load the marker together with the image
   RasterCollection<RasterMarkerMetadata> marker = codecs.ReadMarkers(Path.Combine(ImagesPath.Path,"IMAGE1_MARKERS.JPG"));
   // look for the APP5 marker, because there might be other markers (like APP0, APP1)
   foreach(RasterMarkerMetadata markerItem in marker)
      if(markerItem.Id == RasterMarkerMetadata.App0 + 5)
         MessageBox.Show("marker Id :" + markerItem.Id.ToString() + " = " + markerItem.GetData().ToString());

   codecs.Dispose();
}
RasterImageExamples.prototype.MarkersExample = function () {
   Tools.SetLicense();
   with (Leadtools) {
      with (Leadtools.Codecs) {
         var codecs = new RasterCodecs();
         var srcFileName = "Assets\\Image1.cmp";
         var image;

         return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {

            return codecs.loadAsync(LeadStreamFactory.create(loadFile))
         })
            .then(function (img) {
               image = img;

               var byteData = new Array(1);
               byteData[0] = 40;
               // write APP5 (since nobody writes that)
               var markerData = new RasterMarkerMetadata(RasterMarkerMetadata.app0 + 5, byteData);
               image.markers.append(markerData);

               codecs.options.save.markers = true;
               return Tools.AppLocalFolder().createFileAsync("IMAGE1_MARKERS.JPG")
            })
            .then(function (saveFile) {
               var saveStream = LeadStreamFactory.create(saveFile);
               return codecs.saveAsync(image, saveStream, RasterImageFormat.jpeg, 0)
            })
            .then(function () {
               // load the marker together with the image
               return Tools.AppLocalFolder().getFileAsync("IMAGE1_MARKERS.JPG")
            })
            .then(function (loadFile) {
               return codecs.readMarkersAsync(LeadStreamFactory.create(loadFile))
            })
            .then(function (marker) {
               // look for the APP5 marker, because there might be other markers (like APP0, APP1)
               for (var i = 0; i < marker.length; i++) {
                  var markerItem = marker[i];

                  if (markerItem.id == RasterMarkerMetadata.app0 + 5)
                     console.info("marker Id :" + markerItem.id + " Length : " + markerItem.getData().length);
               }
               image.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 MarkersExample()
{
   RasterCodecs codecs = new RasterCodecs();
   string srcFileName = @"Assets\Image1.cmp";
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));
   byte[] byteData = new byte[1];
   byteData[0] = 40;
   // write APP5 (since nobody writes that)
   RasterMarkerMetadata markerData = new RasterMarkerMetadata(RasterMarkerMetadata.App0 + 5, byteData);
   image.Markers.Add(markerData);

   codecs.Options.Save.Markers = true;
   StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync("IMAGE1_MARKERS.JPG");
   ILeadStream saveStream = LeadStreamFactory.Create(saveFile);
   await codecs.SaveAsync(image, saveStream, RasterImageFormat.Jpeg, 0);

   // load the marker together with the image
   loadFile = await Tools.AppLocalFolder.GetFileAsync("IMAGE1_MARKERS.JPG");
   IList<RasterMarkerMetadata> marker = await codecs.ReadMarkersAsync(LeadStreamFactory.Create(loadFile));
   // look for the APP5 marker, because there might be other markers (like APP0, APP1)
   foreach (RasterMarkerMetadata markerItem in marker)
   {
      if (markerItem.Id == RasterMarkerMetadata.App0 + 5)
         Debug.WriteLine("marker Id :" + markerItem.Id + " Length : " + markerItem.GetData().Length);
   }

   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 MarkersExample(RasterImage image, Stream destStream)
{
   byte[] byteData = new byte[1];
   byteData[0] = 40;
   // write APP5 (since nobody writes that)
   RasterMarkerMetadata markerData = new RasterMarkerMetadata(RasterMarkerMetadata.App0 + 5, byteData);
   image.Markers.Add(markerData);
   RasterCodecs codecs = new RasterCodecs();
   codecs.Options.Save.Markers = true;
   codecs.Save(image, destStream, RasterImageFormat.Jpeg, 0);

   // load the marker together with the image
   RasterCollection<RasterMarkerMetadata> marker = codecs.ReadMarkers(destStream);
   // look for the APP5 marker, because there might be other markers (like APP0, APP1)
   foreach (RasterMarkerMetadata markerItem in marker)
      if (markerItem.Id == RasterMarkerMetadata.App0 + 5)
         Debug.WriteLine("marker Id :" + markerItem.Id.ToString() + " = " + markerItem.GetData().ToString());
}
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 MarkersExample(ByVal image As RasterImage, ByVal destStream As Stream)
   Dim byteData As Byte() = New Byte(0){}
   byteData(0) = 40
   ' write APP5 (since nobody writes that)
   Dim markerData As RasterMarkerMetadata = New RasterMarkerMetadata(RasterMarkerMetadata.App0 + 5, byteData)
   image.Markers.Add(markerData)
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.Options.Save.Markers = True
   codecs.Save(image, destStream, RasterImageFormat.Jpeg, 0)

   ' load the marker together with the image
   Dim marker As RasterCollection(Of RasterMarkerMetadata) = codecs.ReadMarkers(destStream)
   ' look for the APP5 marker, because there might be other markers (like APP0, APP1)
   For Each markerItem As RasterMarkerMetadata In marker
      If markerItem.Id = RasterMarkerMetadata.App0 + 5 Then
         Debug.WriteLine("marker Id :" & markerItem.Id.ToString() & " = " & markerItem.GetData().ToString())
      End If
   Next markerItem
End Sub
必要条件

ターゲットプラットホーム

参照

参照

RasterImageクラス
RasterImageメンバ