Previous Document Next Document

Object Model Reference : Classes : B : Bitmap : Methods : Bitmap.Resample


Bitmap.Resample

Sub Resample([Width As Long], [Height As Long], [AntiAlias As Boolean = True], [ResolutionX As Double], [ResolutionY As Double])

Description

Member of Bitmap

The Resample method resizes a bitmap.

Parameter
Description
Width
Specifies the width. This parameter is optional, and its default value is 0.
Height
Specifies the height. This parameter is optional, and its default value is 0.
AntiAlias
Specifies whether to apply anit-aliasing. This parameter is optional, and its default value is True.
ResolutionX
Specifies the horizontal resolution. This parameter is optional, and its default value is 0.
ResolutionY
Specifies the vertical resolution. This parameter is optional, and its default value is 0.

VBA example

The following VBA example resizes all bitmaps on the active page. All bitmaps fit in a 150 × 150 pixel frame and maintain their original aspect ratio.

Sub Test()
 Dim s As Shape
 Dim Width As Double
 Dim Height As Double
 Dim AspectRatio As Double
 Width = 150
 Height = 150
 For Each s In ActivePage.Shapes
  If s.Type = cdrBitmapShape Then
   'so if thewidth is greater than theheight
   If s.Bitmap.SizeWidth > s.Bitmap.SizeHeight Then
    'the aspect ratio is Height divided by Width
    AspectRatio = s.Bitmap.SizeHeight / s.Bitmap.SizeWidth
    Height = AspectRatio * Width
   'height is greater than width, so
   ElseIf s.Bitmap.SizeHeight > s.Bitmap.SizeWidth Then
    'the aspect ratio is Width divided by Height
    AspectRatio = s.Bitmap.SizeWidth / s.Bitmap.SizeHeight
    Width = AspectRatio * Height
   End If
   s.Bitmap.Resample CLng(Width), CLng(Height)
  End If
 Next s
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.