Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Karl-Heinz" Newsgroups: comp.lang.clipper.visual-objects Subject: Re: Create Bitmap Date: Sat, 11 Feb 2017 13:42:00 +0100 Lines: 70 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=original Content-Transfer-Encoding: 7bit X-Trace: individual.net s236gB50Mg8a2jJpS1Z4vwNEzYXV2VesOlLJBW51rzxgBQmAE= Cancel-Lock: sha1:u8JCPNrGmBMdD4KCPNEsRmX1KbU= In-Reply-To: X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 16.4.3564.1216 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3564.1216 Xref: csiph.com comp.lang.clipper.visual-objects:10150 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