DRAW A TEXT ON A BITMAP
Re: DRAW A TEXT ON A BITMAP
But when I paint a bitmap not call tbitmap control ?
Re: DRAW A TEXT ON A BITMAP
I make a simply test
Now How I can make to click on each umbrellas ?
I need only to click on each umbrellas and open a dialog
I also write the numbers with
// write the numbers
SetBkMode( hDC, 1 )
SetTextColor( hDC, CLR_RED )
TextOut( hDC, nrow, ncol,str(nX) )
but perhaps there is an error
Code: Select all
#include "fivewin.ch"
#define MERGEPAINT 12255782 // 0xBB0226
#define SRCAND 8913094
static oWnd, hBmp1, hBmp2
Function test()
hBmp1 = LoadBitmap( GetResources(), "AZZURRO" )
hBmp2 = LoadBitmap( GetResources(), "ROSSO" )
DEFINE WINDOW oWnd
ACTIVATE WINDOW oWnd ;
ON PAINT ( SayBitmaps() )
DeleteObject( hBmp1 )
DeleteObject( hBmp2 )
return nil
function SayBitmaps()
local hDC := oWnd:GetDC()
lOCAL nRow:=20
Local nCol:=24
TOTY := 20
TOTX := 20
aBmps := ARRAY( TOTY, TOTX )
aData := ARRAY( TOTY, TOTX )
n=1
For nY := 1 to TOTY
For nX := 1 To TOTX
aData[nY,nX] := "X"
DrawBitmap( hDC, hBmp1, nrow, ncol, 0, 0, SRCAND )
// write the number
SetBkMode( hDC, 1 )
SetTextColor( hDC, CLR_RED )
TextOut( hDC, nrow, ncol,str(n) )
n:=n+1
ncol:=ncol+48
Next nX
nRow += 24
nCol := 48
Next nY
oWnd:ReleaseDC()
return nil
Now How I can make to click on each umbrellas ?
I need only to click on each umbrellas and open a dialog
I also write the numbers with
// write the numbers
SetBkMode( hDC, 1 )
SetTextColor( hDC, CLR_RED )
TextOut( hDC, nrow, ncol,str(nX) )
but perhaps there is an error
Last edited by Eoeo on Tue Jul 17, 2012 6:48 pm, edited 1 time in total.
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: DRAW A TEXT ON A BITMAP
I told you to use a Umbrella object for each umbrella, anyhow...
Simply divide Mouse nRow and nCol by 24 and 24 (as you used to paint the umbrellas rows and columns) and you know on which umbrella clicked the mouse
Simply divide Mouse nRow and nCol by 24 and 24 (as you used to paint the umbrellas rows and columns) and you know on which umbrella clicked the mouse
Re: DRAW A TEXT ON A BITMAP
I'm not very able to create a Object instead of a control and I am stop here :
Code: Select all
CLASS Umbrella
DATA nTop, nLeft, nWidth, nHeight
DATA nStatus
DATA cBitmap
DATA oWnd
DATA hBitmap, hPalette
METHOD IsOver( nRow, nCol ) // to detect a mouse click
METHOD New ( cBitmap, oWnd,nTop, nLeft,nWidth, nHeight) CONSTRUCTOR
METHOD Paint( )
METHOD LoadImage(cBmpFile )
ENDCLASS
METHOD New( cBitmap, oWnd,nTop, nLeft,nWidth, nHeight) CLASS Umbrella
DEFAULT cBitmap := ""
::nTop := nTop
::nLeft := nLeft
::nWidth := nWidth
::nHeight := nHeight
::oWnd := oWnd
::LoadImage(cBmpFile )
Return self
METHOD LoadImage(cBmpFile ) CLASS Umbrella
local lChanged := .f.
local hBmpOld := ::hBitmap
local hPalOld := ::hPalette
local aBmpPal
if ! Empty( cBmpFile )
aBmpPal = PalBmpRead( ::GetDC(), AllTrim( cBmpFile ) )
::hBitmap = aBmpPal[ 1 ]
::hPalette = aBmpPal[ 2 ]
::ReleaseDC()
endif
if lChanged
::cBmpFile = cBmpFile
if ! Empty( hBmpOld )
PalBmpFree( hBmpOld, hPalOld )
endif
PalBmpNew( ::hWnd, ::hBitmap, ::hPalette )
endif
return lChanged
METHOD paint()
if Empty( ::hBitmap ) .and. ! Empty( ::cBmpFile )
::LoadImage( ::cBmpFile )
endif
return nil
METHOD IsOver( nRow, nCol ) CLASS Umbrella
return nil
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: DRAW A TEXT ON A BITMAP
Silvio,
Basically you do:
Basically you do:
Code: Select all
function Click( nRow, nCol )
local nMyRow := Int( nRow / 20 )
local nMyCol := Int( nCol / 20 )
MsgInfo( nMyRow * 20 + nMyCol )
return nil
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: DRAW A TEXT ON A BITMAP
If you keep an array of Umbrella objects then you do:
nAt = AScan( aUmbrellas, { | oUmbrella | oUmbrella:IsOver( nRow, nCol ) } )
nAt = AScan( aUmbrellas, { | oUmbrella | oUmbrella:IsOver( nRow, nCol ) } )
Re: DRAW A TEXT ON A BITMAP
Antonio,
I made this class ... perhaps.. but why not show the bitmap ?
I made this class ... perhaps.. but why not show the bitmap ?
Code: Select all
#include "fivewin.ch"
#include "constant.ch"
Function Main()
Local ownd
Local umbrella
DEFINE WINDOW oWnd
umbrella:=Umbrella():New(10,10,oWnd,"azzurro.bmp",,.t.)
ACTIVATE WINDOW oWnd
RETURN NIL
CLASS Umbrella
DATA nTop, nLeft, nWidth, nHeight
DATA nStatus
DATA cBmpFile, cResName, lBorder
DATA hBmp, hBmpPal
DATA oParent
DATA nPen, nStylePen, nClrPen
DATA hDCMem
DATA hOldBmp
CLASSDATA hOld
METHOD New (nTop, nLeft, oParent,;
cBmpFile, cResName, lBorder ) CONSTRUCTOR
METHOD Paint( hDC, nTop, nLeft )
//METHOD IsOver( nRow, nCol ) // to detect a mouse click
METHOD EndPaint()
METHOD BeginPaint( hDC )
METHOD Click( nRow, nCol )
METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0
ENDCLASS
//-----------------------------------------------------------------------/
METHOD New (nTop, nLeft, oParent,;
cBmpFile, cResName, lBorder ) CLASS Umbrella
DEFAULT lBorder := .t.
::oParent := oParent
::nTop := nTop
::nLeft := nLeft
// ::nHeight := nBottom
// ::nWidth := nRight
::cBmpFile := cBmpFile
::cResName := cResName
::lBorder := lBorder
if File( ::cBmpFile )
::hBmp := ReadBitmap (0, cBmpFile )
::hBmpPal := PalBmpRead( ::oParent:GetDC(), AllTrim( cBmpFile ) )
::oParent:ReleaseDC()
if ! Empty( ::hOld )
PalBmpFree( ::hOld )
endif
::hOld := ::hBmpPal
PalBmpNew( ::oParent:hWnd, ::hBmpPal )
::nHeight := nBmpHeight( ::hBmp )
::nWidth := nBmpWidth( ::hBmp )
::nHeight := ::nTop + ::nHeight
::nWidth := ::nLeft + ::nWidth
endif
::Display()
* ::Paint( ::oParent:GetDC() )
Return Self
//-----------------------------------------------------------------------/
METHOD Paint (hDC) CLASS Umbrella
Local hPen, hOldPen
DEFAULT hDC := ::oParent:hDC
hPen := CreatePen (::nStylePen, ::nPen, ::nClrPen)
hOldPen := SelectObject (hDC, hPen)
DrawBitmap (hDC, ::hBmp, ::nTop, ::nLeft, ::nWidth, ::nHeight)
* PALBMPDraw( hDC, ::nTop, ::nLeft, ::hBmpPal, ::nWidth, ::nHeight)
If ::lBorder
Moveto (hDC, ::nLeft, ::nTop)
LineTo( hDC, ::nWidth, ::nTop )
LineTo( hDC, ::nWidth, ::nHeight )
LineTo( hDC, ::nLeft , ::nHeight )
LineTo( hDC, ::nLeft , ::nTop )
endif
SelectObject( hDC, hOldPen )
DeleteObject( hPen )
Return nil
METHOD BeginPaint( hDC )
::hDCMem := CompatDC( hDC )
::hOldBmp := SelectObject( ::hDCMem, ::hBmp )
Return nil
METHOD EndPaint()
SelectObject( ::hDCMem, ::hOldBmp )
DeleteDC( ::hDCMem )
::hDCMem := nil
Return nil
METHOD Click( nRow, nCol )
local nMyRow := Int( nRow / 20 )
local nMyCol := Int( nCol / 20 )
MsgInfo( nMyRow * 20 + nMyCol )
return nil
Re: DRAW A TEXT ON A BITMAP
I tested a Solution with xBrowse :
Using 2000 BMP's without any problem.
It is possible to define 5 horizontal and 5 vertical splittings ( empty Cells ).
I created 95 Cols with 25 Rows
From Tselex, I can change the Status of a Umbrella ( focused Cell ).
It is possible to Zoom IN / OUT
I still have to add the Umbrella-No to the Yellow Cell-parts and the Row-No. on the 1. Col.
Left Mouseclick selects a Cell with a possible Status-change and shows the Row- / Col-Number.
Each Cell belongs to a DBF-record, to save the Umbrella-status.
Best Regards
Uwe
Using 2000 BMP's without any problem.
It is possible to define 5 horizontal and 5 vertical splittings ( empty Cells ).
I created 95 Cols with 25 Rows
From Tselex, I can change the Status of a Umbrella ( focused Cell ).
It is possible to Zoom IN / OUT
I still have to add the Umbrella-No to the Yellow Cell-parts and the Row-No. on the 1. Col.
Left Mouseclick selects a Cell with a possible Status-change and shows the Row- / Col-Number.
Each Cell belongs to a DBF-record, to save the Umbrella-status.
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
Re: DRAW A TEXT ON A BITMAP
I added a Gridpainter.
Now it is possible ( DesignMode ), to define a Value for Rows and Cols
and any Horizontal- / Vertical Splitting.
Exclude any defined Area
A normal Cellstatus belongs to Value 1 - 4. A unused Cell will have the Value 0
In Editmode, it is not possible to change a defined 0-Status.
Changing to < Edit-Mode >, the Settings are saved to the PROJECT.DBF
The Button < New > expects, that Mode is switched to Edit before. That makes it impossible,
to overwrite a existing Project by mystake.
A early Test. There is still the missing Object-counter.
With the JUMP-buttons, I want to move to a defined Cell.
Download :
To change the Cell-status : Left Mouseclick on the Cell and select from < Status 1- 4 >
http://www.pflegeplus.com/fw_downloads/imgxbrw1.zip
Best Regards
Uwe
Now it is possible ( DesignMode ), to define a Value for Rows and Cols
and any Horizontal- / Vertical Splitting.
Exclude any defined Area
A normal Cellstatus belongs to Value 1 - 4. A unused Cell will have the Value 0
In Editmode, it is not possible to change a defined 0-Status.
Changing to < Edit-Mode >, the Settings are saved to the PROJECT.DBF
The Button < New > expects, that Mode is switched to Edit before. That makes it impossible,
to overwrite a existing Project by mystake.
A early Test. There is still the missing Object-counter.
With the JUMP-buttons, I want to move to a defined Cell.
Download :
To change the Cell-status : Left Mouseclick on the Cell and select from < Status 1- 4 >
http://www.pflegeplus.com/fw_downloads/imgxbrw1.zip
Best Regards
Uwe
Last edited by ukoenig on Mon Jul 01, 2013 4:10 pm, edited 1 time 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.
i work with FW.
If you have any questions about special functions, maybe i can help.
Re: DRAW A TEXT ON A BITMAP
Good morning
I have a xBrowse with images
Can you tell me how I can put a text over an image in a cell of a xBrowse?
Excuse my English (google translate)
Thanks in advance
regards
Buenos dias
Tengo un XBrowse con imagenes
Puede indicarme como puedo poner un texto sobre una imagen dentro de una celda de un XBrowse?
Disculpe mi ingles (google translate)
Gracias anticipadas
Saludos
I have a xBrowse with images
Can you tell me how I can put a text over an image in a cell of a xBrowse?
Excuse my English (google translate)
Thanks in advance
regards
Buenos dias
Tengo un XBrowse con imagenes
Puede indicarme como puedo poner un texto sobre una imagen dentro de una celda de un XBrowse?
Disculpe mi ingles (google translate)
Gracias anticipadas
Saludos
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Re: DRAW A TEXT ON A BITMAP
How do You want to display the text ?
Working on a sample, I have to know :
Solution 1 : a centered transparent text
Solution 2 : a text centered, on bottom or top
and with a extra background-color.
Best regards
Uwe
Working on a sample, I have to know :
Solution 1 : a centered transparent text
Solution 2 : a text centered, on bottom or top
and with a extra background-color.
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
Re: DRAW A TEXT ON A BITMAP
Uwe, thanks in advance
Attached image of my application and then as I would like it to appear
regards
Uwe, gracias de antemano
Adjunto imagen de mi aplicacion y despues como me gustaria que apareciese
Saludos
This is my screen
Esta es mi pantalla
I want to put text to images
Quiero poner texto a las imagenes
Thanks for your time
Gracias por tu tiempo
Attached image of my application and then as I would like it to appear
regards
Uwe, gracias de antemano
Adjunto imagen de mi aplicacion y despues como me gustaria que apareciese
Saludos
This is my screen
Esta es mi pantalla
I want to put text to images
Quiero poner texto a las imagenes
Thanks for your time
Gracias por tu tiempo
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Re: DRAW A TEXT ON A BITMAP
ukoenig wrote:How do You want to display the text ?
Working on a sample, I have to know :
Solution 1 : a centered transparent text
Solution 2 : a text centered, on bottom or top
and with a extra background-color.
Best regards
Uwe
This is the code I use to put pictures
Este es el codigo que utilizo para poner las imagenes
Code: Select all
:aCols[1]:aBitmaps := aBitmaps1
:aCols[1]:bStrData := {|| Nil }
//:aCols[1]:lBmpStretch := .T. // Rellenar toda la celda con el BitMap
:aCols[1]:bBmpData := { | oB | oXBrw:nArrayAt }
//:aCols[1]:cHeader := "Nombre de Grupo"
:aCols[1]:nDataStrAlign := 1
:aCols[1]:lAllowSizing := .F.
:aCols[1]:nEditType := 0
Saludos
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Re: DRAW A TEXT ON A BITMAP
To display the Images with text, is a complete different solution.
As a test, I used my MEMORY-game to display the image-names for each cell
with a font-combination :
I still have to add a defined text-color
Best Regards
Uwe
As a test, I used my MEMORY-game to display the image-names for each cell
with a font-combination :
I still have to add a defined text-color
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
Re: DRAW A TEXT ON A BITMAP
Tested transparent PNG and textcolor-change
How can I get the number of a Column, during the xBrowse-build ?
I still need the reached Col or straight the Cell-number !!!
STATIC FUNCTION DRAWTEXT( oCol, hDC, oBrw1, cText, aCoord, oBold, oItalic )
local nTop := aCoord[ 1 ], nLeft := aCoord[ 2 ]
local nBottom := aCoord[ 3 ], nRight := aCoord[ 4 ]
local nRow := nTop
local cLine, nFontHt, nAt
nAt := AT( CRLF, cText )
IF nAt > 0
cLine := Left( cText, nAt - 1 )
oBold:Activate( hDC )
nFontHt := GetTextHeight( oCol:oBrw:hWnd, hDC )
DRAWTEXTEX( hDC, cLine, { nRow, nLeft, nRow + nFontHt + 4, nRight }, 1 ) //oCol:nDataStyle )
oBold:DeActivate( hDC )
nRow += nFontHt + 4
cLine := SubStr( cText, nAt + 2 )
ELSE
cLine := cText
ENDIF
IF oBrw1:KeyNo() = 2 .or. oBrw1:KeyNo() = 4
SetTextColor( hDC, 255 )
ELSE
SetTextColor( hDC, 0 )
ENDIF
oItalic:Activate( hDC )
DRAWTEXTEX( hDC, cLine, { nRow, nLeft, nBottom, nRight }, oCol:nDataStyle )
oItalic:DeActivate( hDC )
RETURN NIL
How can I get the number of a Column, during the xBrowse-build ?
I still need the reached Col or straight the Cell-number !!!
STATIC FUNCTION DRAWTEXT( oCol, hDC, oBrw1, cText, aCoord, oBold, oItalic )
local nTop := aCoord[ 1 ], nLeft := aCoord[ 2 ]
local nBottom := aCoord[ 3 ], nRight := aCoord[ 4 ]
local nRow := nTop
local cLine, nFontHt, nAt
nAt := AT( CRLF, cText )
IF nAt > 0
cLine := Left( cText, nAt - 1 )
oBold:Activate( hDC )
nFontHt := GetTextHeight( oCol:oBrw:hWnd, hDC )
DRAWTEXTEX( hDC, cLine, { nRow, nLeft, nRow + nFontHt + 4, nRight }, 1 ) //oCol:nDataStyle )
oBold:DeActivate( hDC )
nRow += nFontHt + 4
cLine := SubStr( cText, nAt + 2 )
ELSE
cLine := cText
ENDIF
IF oBrw1:KeyNo() = 2 .or. oBrw1:KeyNo() = 4
SetTextColor( hDC, 255 )
ELSE
SetTextColor( hDC, 0 )
ENDIF
oItalic:Activate( hDC )
DRAWTEXTEX( hDC, cLine, { nRow, nLeft, nBottom, nRight }, oCol:nDataStyle )
oItalic:DeActivate( hDC )
RETURN NIL
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.
i work with FW.
If you have any questions about special functions, maybe i can help.