Previous Document Next Document
StructImportResampleOptions.Width

Property Width As Long

Member of StructImportResampleOptions

The following code example creates a new resample-options class. It then imports a JPEG file and resamples it depending on the value for CustomData. Before it applies the resampling, the original settings of the image are displayed.

Copy the following lines of code into a new class module named cResample:

Option Explicit 
Implements IImportResampleHandler 
Private Function IImportResampleHandler_Resample(Options As 
IStructImportResampleOptions) As Boolean 
 Dim s As String 
 s = "Original Settings: " & vbCr 
 s = s & "DpiX: " & Options.DpiX & vbCr 
 s = s & "DpiY: " & Options.DpiY & vbCr 
 s = s & "FileName: " & Options.FileName & vbCr 
 s = s & "Filter: " & Options.FilterID & vbCr 
 ' Display the original settings in a message box 
 MsgBox s 
 ' If the custom data is set to 8, then resample half of the original; 
otherwise 1.5 
 If Options.CustomData = 8 Then 
  Options.Height = Options.Height / 2 
  Options.Width = Options.Width / 2 
 Else 
  Options.Height = Options.Height / 1.5 
  Options.Width = Options.Width / 1.5 
 End If 
End Function 

Copy the following subroutine into a regular module or ThisDocument:

Sub testResample() 
 ' Declare a new resample class. 
 Dim MyResampler As New cResample 
 ' Declare a new import options structure. 
 Dim io As New StructImportOptions 
 ' Change the mode to resample. 
 io.Mode = cdrImportResample 
 ' Set the custom data. 
 io.CustomData = 8 
 ' Set the import options resample handler to the one created. 
 Set io.ResampleHandler = MyResampler 
 ' Import the jpeg file passing the import option structure. 
 ActiveLayer.Import "C:\Test.jpg", , io 
End Sub 

Previous Document Next Document Back to Top

Copyright 2007 Corel Corporation. All rights reserved.