D2BitmapSize command

Requires: Direct2D.lg32

Purpose

Returns a D2Bitmap's size in either device-independent size or in pixels.

Syntax

D2BitmapSize D2Bitmap, width!, height! [,Pixels]

D2Bitmap: Object variable
width!, height!: float variables
Pixels: boolean expression

Description

Without setting Pixels to true the D2BitmapSize returns the size of the bitmap in device independent units. When Pixels is true the command retrieves the device dependent units (pixels) of the bitmap. D2Bitmap must be a valid Direct2D bitmap obtained using the D2Bitmap() function.

Example

'

' D2BitmapSize sample (dpi-unaware)

'

$Library "direct2d"

Global Object Win1RT

OpenW 1, 0, 0, 320, 260, ~15

' DC Rendertarget same size as clientarea

Set Win1RT = D2GetRT()

' Here: Create Win_1 render target resources

Global Object BmpFish

Set BmpFish = D2Bitmap(":goldfish")

Global BmpFishW!, BmpFishH!

D2BitmapSize BmpFish, BmpFishW!, BmpFishH!

Do

Sleep

Until Me Is Nothing

 

Sub Win_1_Paint

D2BeginDraw Win1RT, D2C_White

D2Put 10, 10, BmpFish, BmpFishW!, BmpFishH!

D2Clip

D2EndDraw

EndSub

NOTE: The above example will not run correctly as it relies on an embedded file which is not present in the syntax. The programme with full resources can be found in GFABASIC/Samples/Direct2D/D2BitmapSize.g32.

See Also

D2Bitmap, D2Put

{Created by Sjouke Hamstra; Last updated: 19/03/2021 by James Gaite}