Rapid-Q Documentation by William Yu (c)1999, appended by D.Glodt (c)2000-2004, John Kelly Appendix A: QBITMAPEX

QBITMAPEX Component

INCLUDED IN RAPIDQ2.INC
QBitmapEx is just like a QBITMAP except it supports other goodies like Clipboard paste and copy, alphablending, loading of other graphic formats (JPG, GIF, TGA, etc.) and saving to JPG format if the free NviewLib.DLL is present in the system directory or the directory of application. 
  See limitations.

QBitmapEx Properties
FieldTypeR/WDefaultSupport





PenSize Long RW 1 W

Pen size for draw  line,rectangle and circle


PenStyle Long RW PS_SOLID_BMP W

Pen style , the others values are:
PS_SOLID_BMP=0
PS_DASH_BMP=1
PS_DOT_BMP=2
PS_DASHDOT_BMP=3
PS_DASHDOTDOT_BMP=4
PS_NULL_BMP=5
PS_INSIDEFRAME_BMP=6





QBitmapEx Methods
MethodTypeDescriptionParams

AlphaBlend
SUB(Dest AS QBITMAP, Source AS QBITMAP, PercentBlend AS SINGLE) Blend together two bitmaps 
    (Win98 or higher)
3

PercentBlend is from 0.0 to 1.0.
 If PercentBlend = -1 Then alphaBlending is determined by the Alpha values in Source Bitmap and Pixelformat must be pf32bit (32 bpp). The
output Bitmap will be replaced by the new alpha-blended bitmap. If the sizes of the two bitmaps are not equal the smaller will be stretched to equal the larger one
CopyToClipboard SUB Copy image to clipboard 0
PasteFromClipboard SUB(x%,y%) Paste the image of clipboard 2
GetWidthClipboard FUNCTION as INTEGER Return the image width  of clipboard 0
GetHeightClipboard FUNCTION as INTEGER Return the image height of clipboard 0
CanPaste FUNCTON as BOOLEAN Return true if image présent in the clipboard 0
CircleFilled SUB(x1%,y1%,x2%,y2%,c%,Fill%) Draw a circle filled 6
DrawIco SUB(left%,top%,width%,height%,handle%) Draw an icon 3
  If the width and height parameters  are  0,the icon will show with his dimensions by défault.  
FillSurface SUB(x%,y%,c%) Fill the surface pointed by the color of pixel x,y 3
Flip SUB(x%,y%,width%,height%) Make a miror y 4
InvertColor SUB(x%,y%,width%,height%) Invert color 4
LoadOtherImageSUB(FileName$,Progress&,Language$)Auto load graphics files using either jpeg.dll or Nviewlib format3
Mirror SUB(x%,y%,width%,height%) Make a miror x 4
PointerLONGR
 Returns the memory location of the pixel data:
myBMP.loadFromFile "\RapidQ\Test.bmp" 
Showmessage STR$(myBMP.Pointer)
RectangleFilled SUB(x1%,y1%,x2%,y2%,c%,Fill%) Draw a rectangle filled 6
RoundRectFilled SUB(x1%,y1%,x2%,y2%,x3%,y3%,c%,Fill%) Draw a round rectangle filled 8
LoadOtherImage SUB(FileName$,Progress&,Language$) Auto load graphics files using either jpeg.dll or Nviewlib format 3

Automatically loads a file of type *.ICO; *.JPG; *.GIF; *.DIB; *.TGA;*.PCX and others.  Progress displays a progression bar during  loading of file.(true or false)  Language corresponds to the language supported by DLL (i.e. "Japanese")

(Check the internal variable:
NViewLibPresent = 1
 then Nviewlib.DLL is available
NViewLibPresent AND 2 then jpeg.DLL is available.

RotateFast
SUB(x%, y%, angle as single)
Faster version of rotate, uses GDI
3

Rotate 45 degrees on the bitmap center:
Bitmap.RotateFast(Bitmap.Width/2, Bitmap.Height/2, 45.0)
repeated rotations will distort the bitmap, copy the original before multiple rotations.
SaveAsJpg SUB(FileName$,Quality&) Save image to jpg format 2

"Quality" parameter corresponds to the storage quality. 1 = lowest, 100 = highest
The image Pixel format must be either 16 or 24-bit color
QBitmapEx Example

$TYPECHECK ON
$INCLUDE "RapidQ2.inc"
DECLARE SUB LoadImage

IF NViewLibPresent = 0 THEN
ShowMessage "NviewLib.DLL not found"
Application.Terminate
END IF
DIM TmpBMP AS QBITMAPex
DIM fDialog as QOPENDIALOG

create form as QFORM
Caption = "click me"
width = Screen.Width
height = Screen.Height - 28
OnClick = LoadImage

create canvas as QCanvas
Top = 24
width = Form.ClientWidth
height = Form.ClientHeight - 45
OnClick = LoadImage
end create
end create
Form.ShowModal

SUB LoadImage
fDialog.Caption = "Open files"
'if jpeg.dll is present then all jpeg files will be handled by jpeg.dll
'this dll doesn't have loading errors on some jpeg images
fDialog.filter = "Picture files|*.BMP;*.ICO;*.JPG;*.GIF;*.DIB;*.RLE;*.TGA;*.PCX"
fDialog.FileName= ""
IF fDialog.Execute THEN
TmpBMP.LoadOtherImage(fDialog.FileName, 0,"")
Canvas.Draw(0,0, TmpBMP.BMP)
END IF
END SUB

QBitmapEx Example 2

$INCLUDE "rapidQ2.inc"
$TYPECHECK ON
DECLARE SUB LoadImages
DIM TmpBMP AS QBITMAPex
DIM Src1 AS QBITMAPex 'source 1 for bitmap
DIM Src2 AS QBITMAPex 'source 2 for bmp blending
DIM fDialog as QFILEDIALOG

CREATE form as QFORM
width = Screen.Width
height = Screen.Height - 28
OnClick = LoadImages

create canvas as QCanvas
Top = 24
width = Form.ClientWidth
height = Form.ClientHeight - 45
OnClick = LoadImages
end create
end create
Form.ShowModal

SUB LoadImages
fDialog.Caption = "Open two image files"
IF NviewLibPresent THEN
fDialog.filter = "Picture files|*.BMP;*.ICO;*.JPG;*.GIF;*.TGA;*.PCX"
ELSE
fDialog.filter = "*.bmp (bitmap files)|*.BMP"
END IF
fDialog.FileName= ""
fDialog.MultiSelect = True
IF fDialog.Execute THEN

IF NviewLibPresent THEN
Src1.LoadOtherImage(fDialog.Files(0) + fDialog.Files(1), 0, "")
Src2.LoadOtherImage(fDialog.Files(0) + fDialog.Files(2), 0, "")
ELSE 'just bitmaps
Src1.LoadFromFile(fDialog.Files(0) + fDialog.Files(1))
Src2.LoadFromFile(fDialog.Files(0) + fDialog.Files(2))
END IF
TmpBMP.AlphaBlend(Src1, Src2, 0.5) 'mix 50-50%
' TmpBMP.TransparentMode = tmAlpha
' TmpBMP.AlphaBlend(Src1, Src2, -0.5) 'use alpha channel
Canvas.Draw(0,0, TmpBMP.BMP)
END IF
END SUB

Prev Component Contents Next Component