Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #10150
| From | "Karl-Heinz" <invalid@invalid.invalid> |
|---|---|
| Newsgroups | comp.lang.clipper.visual-objects |
| Subject | Re: Create Bitmap |
| Date | 2017-02-11 13:42 +0100 |
| Message-ID | <eg8f5iFrosU1@mid.individual.net> (permalink) |
| References | <ef3b5261-5f92-4820-b572-fbcd8dae6b1c@googlegroups.com> |
Hi Simon,
>
> Anyone able to help me create a small bitmap in VO code -
> I cant use any other library as I need to compile it into a ReportPro UDF
> function.
>
I translated a C-snippet that creates a colored Bitmap
FUNCTION CreateColoredBitmap ( nWidth AS INT , nHeight AS INT , dwColorref
AS DWORD ) AS PTR PASCAL
LOCAL hDC, hBitMap, hBrush, hTempHDC, hPreviousBitmap AS PTR
LOCAL struRect IS _winRect
SetRect ( @struRect , 0 , 0 , nWidth , nHeight )
hDC := GetDC ( NULL )
hTempHDC := CreateCompatibleDC( hDC)
hBitMap := CreateCompatibleBitmap( hDC, nWidth, nHeight )
hPreviousBitmap := SelectObject( hTempHDC, hBitMap )
// set the color
hBrush := CreateSolidBrush( dwColorref )
FillRect( hTempHDC, @struRect, hBrush )
DeleteObject( hBrush )
SelectObject( hTempHDC, hPreviousBitmap )
DeleteDC( hTempHDC )
DeleteDC ( hDC)
SetBitmapDimensionEx( hBitMap, nWidth, nHeight, NULL)
RETURN hBitMap
The result is a BMP-handle that can be used e.g. with a "Fixed Bitmap"
control
IF ( hBitMap := CreateColoredBitmap( 5, 5 , Color {
COLORGREEN}:colorref ) ) != NULL_PTR
oBitmap := Bitmap { hBitMap }
// Assign the Bitmap to a "Fixed Bitmap" control
oDCFixedBitmap1:SetBitmap ( oBitmap )
ENDIF
If you want to save the created BMP to disk you should include the "Fab
PaintLib.aef" and do something like:
IF ( hDib := DIBCreateFromHBitmap( hBitMap ) ) != NULL_PTR
DIBSaveAs ( hDib , String2Psz("your.bmp" ))
DIBDelete ( hDib )
ENDIF
regards
Karl-Heinz
Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Create Bitmap simon@abersoftware.co.uk - 2017-02-10 03:25 -0800
Re: Create Bitmap "Karl-Heinz" <invalid@invalid.invalid> - 2017-02-11 13:42 +0100
Re: Create Bitmap simon@abersoftware.co.uk - 2017-02-13 03:45 -0800
Re: Create Bitmap "Karl-Heinz" <invalid@invalid.invalid> - 2017-02-13 16:13 +0100
Re: Create Bitmap simon@abersoftware.co.uk - 2017-02-13 09:01 -0800
csiph-web