Object Model Reference : Classes : S : StructImportOptions : Properties : StructImportOptions.ResampleHandler |
Property ResampleHandler As IImportResampleHandler
Member of StructImportOptions
The ResampleHandler property specifies a handler for resampling on import.
The following VBA example creates a new resample-options class. It then imports a JPEG file and resamples it depending on the value for StructImportResampleOptions.CustomData. Before it applies the resampling, the original settings of the image are displayed.
To try out this code example, 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 |
Next, 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 |
Copyright 2013 Corel Corporation. All rights reserved.