Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #10149 > unrolled thread

Create Bitmap

Started bysimon@abersoftware.co.uk
First post2017-02-10 03:25 -0800
Last post2017-02-13 09:01 -0800
Articles 5 — 2 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  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

#10149 — Create Bitmap

Fromsimon@abersoftware.co.uk
Date2017-02-10 03:25 -0800
SubjectCreate Bitmap
Message-ID<ef3b5261-5f92-4820-b572-fbcd8dae6b1c@googlegroups.com>
Hi All,

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.

Tried CreateBitmap() function but cant work out what I need to put in the array to get a coloured block.

HBITMAP CreateBitmap(

    int nWidth,	// bitmap width, in pixels 
    int nHeight,	// bitmap height, in pixels 
    UINT cPlanes,	// number of color planes used by device 
    UINT cBitsPerPel,	// number of bits required to identify a color  
    CONST VOID *lpvBits 	// pointer to array containing color data 
   );

I just need a block of one colour say 5 pixels by 5 pixels.

I looked at CreateCompatibleBitmap() but thats way above my understanding!

Any help appreciated!

Simon

[toc] | [next] | [standalone]


#10150

From"Karl-Heinz" <invalid@invalid.invalid>
Date2017-02-11 13:42 +0100
Message-ID<eg8f5iFrosU1@mid.individual.net>
In reply to#10149
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

[toc] | [prev] | [next] | [standalone]


#10151

Fromsimon@abersoftware.co.uk
Date2017-02-13 03:45 -0800
Message-ID<40963e73-b4ab-4892-bbdd-4f3190291055@googlegroups.com>
In reply to#10149
On Friday, February 10, 2017 at 11:25:08 AM UTC, si...@abersoftware.co.uk wrote:
> Hi All,
> 
> 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.
> 
> Tried CreateBitmap() function but cant work out what I need to put in the array to get a coloured block.
> 
> HBITMAP CreateBitmap(
> 
>     int nWidth,	// bitmap width, in pixels 
>     int nHeight,	// bitmap height, in pixels 
>     UINT cPlanes,	// number of color planes used by device 
>     UINT cBitsPerPel,	// number of bits required to identify a color  
>     CONST VOID *lpvBits 	// pointer to array containing color data 
>    );
> 
> I just need a block of one colour say 5 pixels by 5 pixels.
> 
> I looked at CreateCompatibleBitmap() but thats way above my understanding!
> 
> Any help appreciated!
> 
> Simon

Thanks Karl-Heinz, That works great.

Thanks also to Dave who also gave me a solution.

I did cheat slightly and created a range of Bitmaps for all colours (about 200 of them) so I wouldn't have to create a UDF in reportpro and create the bitmaps on the fly. I doubt ReportPro would like linking through to FabPaint lib to do the saving etc.

Simon

[toc] | [prev] | [next] | [standalone]


#10153

From"Karl-Heinz" <invalid@invalid.invalid>
Date2017-02-13 16:13 +0100
Message-ID<ege0u8F4nloU1@mid.individual.net>
In reply to#10151
Hi Simon,

>
> I did cheat slightly and created a range of
> Bitmaps for all colours (about 200 of them)
>

puuh ... really ?

>
> I doubt ReportPro would like linking through
> to FabPaint lib to do the saving etc.
>

Why shouldn´t that work ? When you import the mentioned Fab lib.aef and add
that lib to the list of libs used by the Report Pro UDF Lib all the Dibxxx
funcs become visible. At last, copy the FabPaint.dll to your runtime dir and
you´re done.

Anyway I. - Hopefully you won't regret it when you have to create another
200 or maybe 400 Bitmaps manually ;-)

Anyway II. - If you rethink your way of doing things, here´s an offer ;-)


-------------

CreateAndSaveColoredBitmap ( 60 , 60 , DWORD(RGB ( 255 , 255, 0 ) )  ,
"D:\Test\Colored.Bmp" )

-------------

FUNCTION  CreateAndSaveColoredBitmap ( nWidth AS INT , nHeight AS INT ,
dwColorref AS DWORD ,  cFileName AS STRING ) AS LOGIC PASCAL
LOCAL lDone AS LOGIC
LOCAL hBitMap, hDib AS PTR


    IF ( hBitMap := CreateColoredBitmap( nWidth , nHeight , dwColorref ) )
!= NULL_PTR

        IF ( hDib := DIBCreateFromHBitmap( hBitMap ) ) != NULL_PTR

             DIBSaveAs ( hDib , String2Psz( cFileName ))

            DIBDelete ( hDib )

           lDone := TRUE

        ENDIF

    ENDIF


    IF hBitMap != NULL_PTR

        DeleteObject ( hBitMap )

    ENDIF



    RETURN lDone



regards
Karl-Heinz 

[toc] | [prev] | [next] | [standalone]


#10154

Fromsimon@abersoftware.co.uk
Date2017-02-13 09:01 -0800
Message-ID<322dcdba-02f9-42e2-8c73-4f7d605aae13@googlegroups.com>
In reply to#10149
On Friday, February 10, 2017 at 11:25:08 AM UTC, si...@abersoftware.co.uk wrote:
> Hi All,
> 
> 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.
> 
> Tried CreateBitmap() function but cant work out what I need to put in the array to get a coloured block.
> 
> HBITMAP CreateBitmap(
> 
>     int nWidth,	// bitmap width, in pixels 
>     int nHeight,	// bitmap height, in pixels 
>     UINT cPlanes,	// number of color planes used by device 
>     UINT cBitsPerPel,	// number of bits required to identify a color  
>     CONST VOID *lpvBits 	// pointer to array containing color data 
>    );
> 
> I just need a block of one colour say 5 pixels by 5 pixels.
> 
> I looked at CreateCompatibleBitmap() but thats way above my understanding!
> 
> Any help appreciated!
> 
> Simon

Hahahahahaha......

My cheat wasn't that much hard work :) I just went through each colour in the file and created the files in a loop using yours and Daves code! So I can recreate them if I need to within the main program.

You have convinced me to try and get it working within a ReportPro UDF! A much nicer solution all round!

Thanks again for all your help!

Simon

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web