LEADTOOLS画像ファイルサポート(Leadtools.Codecsアセンブリ)

フレームを表示

ReadThumbnail(String、CodecsThumbnailOptions、Int32)メソッド








サムネイル画像が作成されるファイルの名前を含むString
サムネイル画像を作成するためのオプション。
サムネイル画像が作成されなければならないページの1から始まるインデックス。
指定された画像ファイルからサムネイルを作成します。
構文
'Declaration
 
Public Overloads Function ReadThumbnail( _
   ByVal fileName As String, _
   ByVal options As CodecsThumbnailOptions, _
   ByVal pageNumber As Integer _
) As RasterImage
'Usage
 
Dim instance As RasterCodecs
Dim fileName As String
Dim options As CodecsThumbnailOptions
Dim pageNumber As Integer
Dim value As RasterImage
 
value = instance.ReadThumbnail(fileName, options, pageNumber)
- (nullable LTRasterImage *)readThumbnailFromFile:(NSString *)file 
                                          options:(LTCodecsThumbnailOptions *)thumbnailOptions 
                                       pageNumber:(NSInteger)pageNumber 
                                            error:(NSError **)error
            
 function Leadtools.Codecs.RasterCodecs.ReadThumbnail(String,CodecsThumbnailOptions,Int32)( 
   fileName ,
   options ,
   pageNumber 
)

パラメーター

fileName
サムネイル画像が作成されるファイルの名前を含むString
オプション
サムネイル画像を作成するためのオプション。
pageNumber
サムネイル画像が作成されなければならないページの1から始まるインデックス。

戻り値

このメソッドが作成するRasterImageオブジェクト。
解説
このメソッドは、常にサムネイル画像を返します。渡されるオプションに従い、このメソッドはEXIF、CMP、JFIFとFlashPixファイルの中に保存されるスタンプを読むかもしれなくて、それを返すかもしれません。ファイルスタンプのみを読み取るには、ReadStampを使います。
サンプル

このサンプルは、CMPファイルからサムネイルを読みます

Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Drawing
Imports Leadtools.Svg

      
Public Sub ReadThumbnailExample()
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")

   ' Create a thumbnail with default options
   Dim options As CodecsThumbnailOptions = CodecsThumbnailOptions.Default
   options.LoadStamp = False
   Dim thumbnail As RasterImage = codecs.ReadThumbnail(srcFileName, options, 1)

   Console.WriteLine("Thumbnail with default option:")
   Console.WriteLine("  Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel)
   thumbnail.Dispose()

   ' Create a thumbnail with some options
   options.LoadStamp = False
   options.Width = 40
   options.Height = 80
   options.ForceSize = True
   options.MaintainAspectRatio = False
   options.BackColor = RasterColor.FromKnownColor(RasterKnownColor.LightBlue)
   options.BitsPerPixel = 8
   thumbnail = codecs.ReadThumbnail(srcFileName, options, 1)

   Console.WriteLine("Thumbnail with set option (size: {0} by {1}, Bits/Pixel: {2}, ForeSize: {3}", options.Width, options.Height, options.BitsPerPixel, options.ForceSize)
   Console.WriteLine("  Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel)
   thumbnail.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.Color;
using Leadtools.Svg;

      
public void ReadThumbnailExample()
{
   RasterCodecs codecs = new RasterCodecs();
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");

   // Create a thumbnail with default options
   CodecsThumbnailOptions options = CodecsThumbnailOptions.Default;
   options.LoadStamp = false;
   RasterImage thumbnail = codecs.ReadThumbnail(srcFileName, options, 1);

   Console.WriteLine("Thumbnail with default option:");
   Console.WriteLine("  Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel);
   thumbnail.Dispose();

   // Create a thumbnail with some options
   options.LoadStamp = false;
   options.Width = 40;
   options.Height = 80;
   options.ForceSize = true;
   options.MaintainAspectRatio = false;
   options.BackColor = RasterColor.FromKnownColor(RasterKnownColor.LightBlue);
   options.BitsPerPixel = 8;
   thumbnail = codecs.ReadThumbnail(srcFileName, options, 1);

   Console.WriteLine("Thumbnail with set option (size: {0} by {1}, Bits/Pixel: {2}, ForeSize: {3}",
      options.Width, options.Height, options.BitsPerPixel, options.ForceSize);
   Console.WriteLine("  Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel);
   thumbnail.Dispose();

   codecs.Dispose();
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
RasterCodecsExamples.prototype.ReadThumbnailExample = function () {
   Tools.SetLicense();
   with (Leadtools) {
      with (Leadtools.Codecs) {
         var codecs = new RasterCodecs();

         var srcFileName = "Assets\\Image1.cmp";
         var thumbnail;
         var loadFile;
         // Create a thumbnail with default options 
         var options = new CodecsThumbnailOptions();
         options.loadStamp = false;
         return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFileX) {
            loadFile = loadFileX;
            return codecs.readThumbnailAsync(LeadStreamFactory.create(loadFile), options, 1)
         })
         .then(function (thumb) {
            thumbnail = thumb;

            console.info("Thumbnail with default option:");
            console.info("  Size: ", thumbnail.width, " by ", thumbnail.Height, "pixels. Bits/Pixel: ", thumbnail.bitsPerPixel);
            thumbnail.close();

            // Create a thumbnail with some options
            options.loadStamp = false;
            options.width = 40;
            options.height = 80;
            options.forceSize = true;
            options.maintainAspectRatio = false;
            options.backColor = RasterColorHelper.fromKnownColor(RasterKnownColor.lightBlue);
            options.bitsPerPixel = 8;
            return codecs.readThumbnailAsync(LeadStreamFactory.create(loadFile), options, 1)
         })
         .then(function (thumb2) {
            thumbnail = thumb2;

            console.info("Thumbnail with set option (size: ", options.width, " by ", options.height, ", Bits/Pixel: ", options.bitsPerPixel, ", ForeSize: ", options.forceSize);
            console.info("  Size: ", thumbnail.width, " by ", thumbnail.height, " pixels. Bits/Pixel: ", thumbnail.bitsPerPixel);
            thumbnail.close();

            codecs.close();
         });
      }
   }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;

      
public async Task ReadThumbnailExample()
{
   RasterCodecs codecs = new RasterCodecs();
   string srcFileName = @"Assets\Image1.cmp";

   // Create a thumbnail with default options 
   CodecsThumbnailOptions options = new CodecsThumbnailOptions();
   options.LoadStamp = false;
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage thumbnail = await codecs.ReadThumbnailAsync(LeadStreamFactory.Create(loadFile), options, 1);

   Debug.WriteLine("Thumbnail with default option:");
   Debug.WriteLine("  Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel);
   thumbnail.Dispose();

   // Create a thumbnail with some options
   options.LoadStamp = false;
   options.Width = 40;
   options.Height = 80;
   options.ForceSize = true;
   options.MaintainAspectRatio = false;
   options.BackColor = RasterColorHelper.FromKnownColor(RasterKnownColor.LightBlue);
   options.BitsPerPixel = 8;
   thumbnail = await codecs.ReadThumbnailAsync(LeadStreamFactory.Create(loadFile), options, 1);

   Debug.WriteLine("Thumbnail with set option (size: {0} by {1}, Bits/Pixel: {2}, ForeSize: {3}",
      options.Width, options.Height, options.BitsPerPixel, options.ForceSize);
   Debug.WriteLine("  Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel);
   thumbnail.Dispose();

   codecs.Dispose();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Examples;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Windows.Media;

public void ReadThumbnailExample(Stream inStreamCmp)
{
   RasterCodecs codecs = new RasterCodecs();
   // Create a thumbnail with default options
   CodecsThumbnailOptions options = CodecsThumbnailOptions.Default;
   options.LoadStamp = false;
   RasterImage thumbnail = codecs.ReadThumbnail(inStreamCmp, options, 1);

   Debug.WriteLine("Thumbnail with default option:");
   Debug.WriteLine("  Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel);
   thumbnail.Dispose();

   // Create a thumbnail with some options
   options.LoadStamp = false;
   options.Width = 40;
   options.Height = 80;
   options.ForceSize = true;
   options.MaintainAspectRatio = false;
   options.BackColor = new RasterColor(0x00, 0x00, 0x7F);
   options.BitsPerPixel = 8;
   thumbnail = codecs.ReadThumbnail(inStreamCmp, options, 1);

   Debug.WriteLine("Thumbnail with set option (size: {0} by {1}, Bits/Pixel: {2}, ForeSize: {3}",
      options.Width, options.Height, options.BitsPerPixel, options.ForceSize);
   Debug.WriteLine("  Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel);
   thumbnail.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Windows.Media

Public Sub ReadThumbnailExample(ByVal inStreamCmp As Stream)
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' Create a thumbnail with default options
   Dim options As CodecsThumbnailOptions = CodecsThumbnailOptions.Default
   options.LoadStamp = False
   Dim thumbnail As RasterImage = codecs.ReadThumbnail(inStreamCmp, options, 1)

   Debug.WriteLine("Thumbnail with default option:")
   Debug.WriteLine("  Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel)
   thumbnail.Dispose()

   ' Create a thumbnail with some options
   options.LoadStamp = False
   options.Width = 40
   options.Height = 80
   options.ForceSize = True
   options.MaintainAspectRatio = False
   options.BackColor = New RasterColor(&H00, &H00, &H7F)
   options.BitsPerPixel = 8
   thumbnail = codecs.ReadThumbnail(inStreamCmp, options, 1)

   Debug.WriteLine("Thumbnail with set option (size: {0} by {1}, Bits/Pixel: {2}, ForeSize: {3}", options.Width, options.Height, options.BitsPerPixel, options.ForceSize)
   Debug.WriteLine("  Size: {0} by {1} pixels. Bits/Pixel: {2}", thumbnail.Width, thumbnail.Height, thumbnail.BitsPerPixel)
   thumbnail.Dispose()
End Sub
必要条件

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

参照

参照

RasterCodecsクラス
RasterCodecsメンバ
オーバーロードリスト
サムネイルブラウザ