Bitmap sizes

Bitmap sizes

Postby Euclides » Wed Aug 13, 2008 1:37 pm

Hi to all!
It there a way to get the bitmap sizes (width & height) read by ReadBitmap() function ?
TIA & Regards, Euclides
User avatar
Euclides
 
Posts: 154
Joined: Wed Mar 28, 2007 1:19 pm

BMP Widht and height

Postby ukoenig » Wed Aug 13, 2008 2:31 pm

Hello,

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

nBMPWIDTH := oBmp:Super:nWidth()
nBMPHIGHT := oBmp:Super: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 :

Image

Code: Select all  Expand view

// 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 :lol:
Last edited by ukoenig on Wed Aug 13, 2008 4:06 pm, edited 3 times in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Bitmap sizes

Postby nageswaragunupudi » Wed Aug 13, 2008 3: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
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Euclides » Thu Aug 14, 2008 1:18 am

Hi Uwe and NageswaraRao, thanks for the help.
NageswaraRao´s info solved my problem
Regards, Euclides
User avatar
Euclides
 
Posts: 154
Joined: Wed Mar 28, 2007 1:19 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 101 guests