Platforms to show: All Mac Windows Linux Cross-Platform

Back to graphics class.

graphics.StretchDIBitsMBS(XDest as Integer, YDest as Integer, DestWidth as Integer, DestHeight as Integer, XSource as Integer, YSource as Integer, SourceWidth as Integer, SourceHeight as Integer, Bits as memoryblock, ImageWidth as Integer, ImageHeight as Integer, ImageBitCount as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Graphics & Pictures MBS Picture Plugin 10.1 ❌ No ✅ Yes ❌ No ❌ No Desktop only
The StretchDIBits function copies the color data for a rectangle of pixels in a DIB image to the specified destination rectangle.
Example
dim m as MemoryBlock
dim p,q as Picture

p=New Picture(100,100,32)
p.Graphics.ForeColor=rgb(255,128,1)
p.Graphics.FillRect 0,0,100,100

// Make a new MemoryBlock
m=NewMemoryBlock(100*100*3) // 3 bytes per Pixel

// Copy RGB without alpha
if p.CopyBGRtoMemoryblockMBS(m,0) then

dim XDest as Integer = 0
dim YDest as Integer = 0
dim DestWidth as Integer = 100
dim DestHeight as Integer = 100
dim XSource as Integer = 0
dim YSource as Integer = 0
dim SourceWidth as Integer = 100
dim SourceHeight as Integer = 100
dim Bits as memoryblock = m
dim ImageWidth as Integer = 100
dim ImageHeight as Integer = 100
dim ImageBitCount as Integer = 24

call g.StretchDIBitsMBS(XDest, YDest, DestWidth, DestHeight, XSource, YSource, SourceWidth, SourceHeight, bits, ImageWidth, ImageHeight, ImageBitCount)

end if

If the destination rectangle is larger than the source rectangle, this function stretches the rows and columns of color data to fit the destination rectangle. If the destination rectangle is smaller than the source rectangle, this function compresses the rows and columns by using the specified raster operation.

You specify the dest rectangle in the graphics object, the source rectangle in the picture, the memoryblock with the bits, the size of the image and the bit count of the image (24 or 32).

The origin of a bottom-up DIB is the bottom-left corner; the origin of a top-down DIB is the upper-left corner.

StretchDIBits creates a mirror image of a bitmap if the signs of the nSrcWidth and nDestWidth parameters, or if the nSrcHeight and nDestHeight parameters differ. If nSrcWidth and nDestWidth have different signs, the function creates a mirror image of the bitmap along the x-axis. If nSrcHeight and nDestHeight have different signs, the function creates a mirror image of the bitmap along the y-axis.

Returns true on success and false on failure.

The items on this page are in the following plugins: MBS Picture Plugin.


The biggest plugin in space...