[.NETコントロール] A5サイズの画像を2枚合成してA4サイズの画像を作成できますか?

文書番号 : 32861     文書種別 : 使用方法     登録日 : 2012/05/10     最終更新日 : 2014/07/10
文書を印刷する
対象製品
LEADTOOLS 17.5J Imaging Pro Suite
詳細
以下の手順にて作成できます。

(1)A4サイズのベース画像を作成します。
(2)A5サイズの画像をCombineFastCommandクラスを使用して合成します。

同様の手順でA4サイズの画像を2枚合成してA3サイズの画像を作成できます。

サンプルコード(VB.NET)
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing


' 画像をロード/保存するためのRasterCodecsオブジェクト
Private codecs As RasterCodecs

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  ' RasterCodecsオブジェクトを初期化します。
  codecs = New RasterCodecs
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  Dim tempImage1 As RasterImage = codecs.Load("A5Size_1.tif")
  Dim tempImage2 As RasterImage = codecs.Load("A5Size_2.tif")

  ' 画像をビューア1に設定します。
  RasterImageViewer1.Image = tempImage1
 
  ' 画像をビューア2に設定します。
  RasterImageViewer2.Image = tempImage2

  RasterImageViewer1.SizeMode = RasterPaintSizeMode.Fit
  RasterImageViewer2.SizeMode = RasterPaintSizeMode.Fit
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  ' A5の画像を合成するためのA4サイズのベース画像を作成します。
  Dim baseImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, _
                                                       787, 1123, 24, RasterByteOrder.Bgr, _
                                                       RasterViewPerspective.TopLeft, Nothing, IntPtr.Zero, 0)

  ' ビットマップを白で塗りつぶします。
  Dim command2 As FillCommand = New FillCommand
  command2.Color = New Leadtools.RasterColor(255, 255, 255)
  command2.Run(baseImage)

  ' ビューア3に設定します。
  RasterImageViewer3.Image = baseImage
  RasterImageViewer3.SizeMode = RasterPaintSizeMode.Fit

  ' ビューア1の画像を合成します。
  Dim command3 As CombineFastCommand = New CombineFastCommand
  command3.DestinationRectangle = New LeadRect(0, 0, RasterImageViewer1.Image.Width, RasterImageViewer1.Image.Height)
  command3.SourcePoint = New LeadPoint(0, 0)
  command3.DestinationImage = RasterImageViewer3.Image
  command3.Flags = CombineFastCommandFlags.OperationAdd Or CombineFastCommandFlags.Destination0
  command3.Run(RasterImageViewer1.Image)

  ' ビューア2の画像を合成します。
  Dim command4 As CombineFastCommand = New CombineFastCommand
  command4.DestinationRectangle = New LeadRect(0, 561, RasterImageViewer2.Image.Width, RasterImageViewer2.Image.Height)
  command4.SourcePoint = New LeadPoint(0, 0)
  command4.DestinationImage = RasterImageViewer3.Image
  command4.Flags = CombineFastCommandFlags.OperationAdd Or CombineFastCommandFlags.Destination0
  command4.Run(RasterImageViewer2.Image)

  ' 結果画像を保存します。
  codecs.Save(RasterImageViewer3.Image, "A4.tif", RasterImageFormat.Tif, 24)
End Sub

サンプルコード(C#)
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;


// 画像をロード/保存するためのRasterCodecsオブジェクト
private RasterCodecs codecs; 

private void Form1_Load(object sender, System.EventArgs e) 
{ 
  // RasterCodecsオブジェクトを初期化します。 
  codecs = new RasterCodecs(); 
} 

private void Button1_Click(object sender, System.EventArgs e) 
{ 
  RasterImage tempImage1 = codecs.Load("A5Size_1.tif"); 
  RasterImage tempImage2 = codecs.Load("A5Size_2.tif"); 
    
  // 画像をビューア1に設定します。 
  rasterImageViewer1.Image = tempImage1;
    
  // 画像をビューア2に設定します。 
  rasterImageViewer2.Image = tempImage2;
    
  rasterImageViewer1.SizeMode = RasterPaintSizeMode.Fit;
  rasterImageViewer2.SizeMode = RasterPaintSizeMode.Fit;
} 

private void Button2_Click(object sender, System.EventArgs e) 
{ 
  // A5の画像を合成するためのA4サイズのベース画像を作成します。 
  RasterImage baseImage = new RasterImage(RasterMemoryFlags.Conventional, 787, 1123, 24, 
                               RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, null, IntPtr.Zero , 0);
    
  // ビットマップを白で塗りつぶします。 
  FillCommand command2 = new FillCommand();
  command2.Color = new Leadtools.RasterColor(255, 255, 255);
  command2.Run(baseImage);
    
  // ビューア3に設定します。 
  rasterImageViewer3.Image = baseImage;
  rasterImageViewer3.SizeMode = RasterPaintSizeMode.Fit;
    
  // ビューア1の画像を合成します。 
  CombineFastCommand command3 = new CombineFastCommand();
  command3.DestinationRectangle = new LeadRect(0, 0, rasterImageViewer1.Image.Width, rasterImageViewer1.Image.Height);
  command3.SourcePoint = new LeadPoint(0, 0);
  command3.DestinationImage = rasterImageViewer3.Image;
  command3.Flags = CombineFastCommandFlags.OperationAdd | CombineFastCommandFlags.Destination0;
  command3.Run(rasterImageViewer1.Image); 
    
  // ビューア2の画像を合成します。 
  CombineFastCommand command4 = new CombineFastCommand();
  command4.DestinationRectangle = new LeadRect(0, 561, rasterImageViewer2.Image.Width, rasterImageViewer2.Image.Height);
  command4.SourcePoint = new LeadPoint(0, 0);
  command4.DestinationImage = rasterImageViewer3.Image;
  command4.Flags = CombineFastCommandFlags.OperationAdd | CombineFastCommandFlags.Destination0;
  command4.Run(rasterImageViewer2.Image);
    
  // 結果画像を保存します。 
  codecs.Save(rasterImageViewer3.Image, "A4.tif", RasterImageFormat.Tif, 24); 
} 
関連情報
キーワード
HowTo 画像処理 合成