Requires: Direct2D.lg32
Draws the specified D2Bitmap.
D2Put x!, y!, D2Bitmap [, w!, h!] [,Opacity!] [,sx!, sy!, sw!, sh!][,interpolation%]
D2Bitmap | : Object variable |
x!, y!, w!, h!, Opacity!,sx!, sy!, sw!, sh! | : float expression |
interpolation% | : iexp |
D2Put renders the D2Bitmap object in the current render target's coordinate space at position x, y in device-independent pixels. Optionally the size of the output rectangle can be set by specifying a value for w and h: the bitmap is stretched or shrunk to fit within the size. If w and h are omitted the size of the bitmap is used.
Opacity sets a value between 0.0f and 1.0f (default), inclusive, that specifies an opacity value to apply to the bitmap; this value is multiplied against the alpha values of the bitmap's contents.
The optional sx!, sy!, sw!, sh! parameters determine the block (position and size) of the bitmap to copy to the destination. If either sw or sh is zero the entire bitmap is copied.
The interpolation mode (antialiasing) can be set for bitmaps that are scaled, either by using w! and h! or by using the D2Transform command. By default, the scaled bitmap is drawn using the render target's current antialiasing setting. So, if antialiasing isn't changed using D2AntiAliasing the bitmap is drawn antialiased. An application can use the interpolation parameter to override the current antialiasing setting and it can have one of two values:
'
' D2Put 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")
Do
Sleep
Until Me Is Nothing
Sub Win_1_Paint
D2BeginDraw Win1RT, D2C_White
D2Put 10, 10, BmpFish
D2EndDraw
EndSub
NOTE: The above example will not run 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/D2Put.g32.
'
' D2Put/interpolationmode 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 Bmp
Set Bmp = D2Bitmap(":icon")
Do
Sleep
Until Me Is Nothing
Sub Win_1_Paint
D2BeginDraw Win1RT, D2C_White
' See effect of interpolationmode
' Draw anti-aliased (default): interpolationmode = D2D1_BITMAP_INTERPOLATION_MODE_LINEAR
D2Put 10, 10, Bmp ' draw antialised
D2AntiAlias False ' no anti-aliasing when scaling
D2Put 50, 10, Bmp, 64, 64 ' scale by 2
D2AntiAlias True ' back to default
' Draw not anti-aliased: interpolationmode: D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR (0)
' Need some transformation, here SKEW transformmode
D2Transform D2TF_SKEW , 10, 10, 10, 70 ' skew around (10,10)
D2Put 10, 70, Bmp, , , , , , , , 0
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/D2Put2.g32.
D2Put must be used between D2BeginDraw and D2EndDraw. The current render target for output must be the same as the render target used to load the bitmap using D2Bitmap().
The bitmap is drawn by the ID2D1RenderTarget::DrawBitmap method using D2D1_BITMAP_INTERPOLATION_MODE_LINEAR for the interpolation.
{Created by Sjouke Hamstra; Last updated: 19/03/2021 by James Gaite; Other Contributors: Jean-Marie Melanson}