Previous Document Next Document

Object Model Reference : Classes : S : StructImportCropOptions : Properties : StructImportCropOptions.ImageWidth


StructImportCropOptions.ImageWidth

Property ImageWidth As Long

Description

Member of StructImportCropOptions

The ImageWidth property specifies the image width of a crop on import.

The ImageWidth property returns a read-only value.

VBA example

The following VBA example creates a new crop-options class. It then imports a JPEG file and crops it depending on the value for StructImportCropOptions.CustomData. Before the crop is applied, 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 cCrop:

Option Explicit
Implements IImportCropHandler
Private Function IImportCropHandler_Crop(Options As IStructImportCropOptions) 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
 s = s & "ImageHeight: " & Options.ImageHeight & vbCr
 s = s & "ImageWidth: " & Options.ImageWidth & vbCr
 ' Display the original settings in a message box
 MsgBox s
 ' If the custom data is set to 7 then crop half of the original; otherwise, subtract 0.5 units from the height and width.
 If Options.CustomData = 7 Then
  Options.Height = Options.Height / 2
  Options.Width = Options.Width / 2
  Options.Top = Options.Top / 2
  Options.Left = Options.Left / 2
 Else
  Options.Height = Options.Height - 0.5
  Options.Width = Options.Width - 0.5
 End If
End Function

Next, copy the following subroutine into a regular module or ThisDocument:

Sub testCrop()
 ' Declare a new crop class.
 Dim MyCrop As New cCrop
 ' Declare a new import options structure.
 Dim io As New StructImportOptions
 ' Change the mode to crop.
 io.Mode = cdrImportCrop
 ' Set the custom data.
 io.CustomData = 7
 ' Set the import options crop handler to the one created.
 Set io.CropHandler = MyCrop
 ' 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 2013 Corel Corporation. All rights reserved.