FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bitmap sizes
Posts: 159
Joined: Wed Mar 28, 2007 01:19 PM
Bitmap sizes
Posted: Wed Aug 13, 2008 01:37 PM

Hi to all!
It there a way to get the bitmap sizes (width & height) read by ReadBitmap() function ?
TIA & Regards, Euclides

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
BMP Widht and height
Posted: Wed Aug 13, 2008 02:31 PM
Hello,

I think, that works.
I used it in my old ONPAINT-function :

nBMPWIDTH := oBmp:nWidth()
nBMPHIGHT := oBmp:nHeight()

Before FWH 8.07, i used it for painting text on gradient-bmp's.
With FWH 8.07 it is easy to handle.
If you don't work with FWH 8.07, you can use this function.

The function includes some more informations, about
Bitmap-handling. Maybe you find something, you can use.

For this BMP, I had to do :



// using FWH-function : Gradient( hDC, aRect, nVColor, nBColor, .T. )
// -----------------------------------------------------------------------
// nVcolor = 1. Gradient-color
// nBColor = 2. Gradient-color
// nColor = Text-color
// cText = String
// e_oBfont2 = Font
// B_Posleft = Left Start-pos. of text
// B_Orient = Hor. / Vert.
// B_Brush = Brush used if no gradient needed
// B_pen = Box-frame
// B_End = Row-position of browser-selection

FUNCTION ONPAINTT( hDC,oBmp, nVcolor, nBColor, nColor, cText, ;
    e_oBfont2, B_POSLEFT, B_END,B_ORIENT, B_BRUSH, B_PEN )
LOCAL hOldFont, oNewbrush

hOldFont := SelectObject( hDC, e_oBFont2:hFont )

nTXTLG :=  GettextWidth( hDC, cText ) 

// Your values !!!!
// ------------------
nBMPWIDTH := oBmp:Super:nWidth() 
nBMPHIGHT := oBmp:Super:nHeight() 

nFONTHIGHT := e_oBfont2:nInpHeight * -1 

nLEFT := 0
IF B_POSLEFT = 0
   nLEFT := nBMPHIGHT - ((nBMPHIGHT - nTXTLG) / 2) 
ELSE
   nLEFT := nBMPHIGHT - nLeft
ENDIF

nNEWHIGHT := nFONTHIGHT

nTOP := (nBMPWIDTH - nNEWHIGHT) / 2

// Browser selection ( brushes if not using colors )
// ---------------------------------------------------------
IF B_END = 8 
   DEFINE BRUSH oNewBrush  STYLE BORLAND
ENDIF
IF B_END = 9
  DEFINE BRUSH oNewBrush  STYLE TILED       
ENDIF
IF B_END = 10
   DEFINE BRUSH oNewBrush  STYLE BRICKS   
ENDIF
IF B_END = 12
   DEFINE BRUSH oNewBrush  FILE B_BRUSH 
ENDIF

aRect := GETCLIENTRECT( oBmp:hWnd )

IF B_END <> 8 .and. B_END <> 9 .and. B_END <> 10 ;
    .and. B_END <> 12
    // Horizontal
    nGRADIENT := Gradient( hDC, aRect, nVColor, nBColor, .T. )  
    IF B_ORIENT = 2
        // Vertical
        nGRADIENT := Gradient( hDC, aRect, nVColor, BColor, .F. )  
    ENDIF
    oBmp:oBrush := TBrush():New( , nGRADIENT )  
ELSE
   oBmp:oBrush := oNewbrush 
ENDIF

FillRect( hDC, aRect, oBmp:oBrush:hBrush )
SetBkMode( hDC, 0 )   // 1 = Transparent

SetTextColor( hDC,nColor)

TextOut( hDC,  nLEFT, nTOP, cText ) 

SelectObject( hDC, hOldFont )

IF B_PEN > 0
   DRAWBOX( aRect, hDC, nColor, nBMPWIDTH, nBMPHIGHT, B_PEN ) 
ENDIF

RETURN NIL


Best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bitmap sizes
Posted: Wed Aug 13, 2008 03:43 PM
Euclides wrote:Hi to all!
It there a way to get the bitmap sizes (width & height) read by ReadBitmap() function ?
TIA & Regards, Euclides


nBmpWidth( hBmp )
nBmpHeight( hBmp )

Source: \fwh\source\function\fwbmp.c
Regards



G. N. Rao.

Hyderabad, India
Posts: 159
Joined: Wed Mar 28, 2007 01:19 PM
Bitmap sizes
Posted: Thu Aug 14, 2008 01:18 AM

Hi Uwe and NageswaraRao, thanks for the help.
NageswaraRao´s info solved my problem
Regards, Euclides

Continue the discussion