Draw on top of a photo

Draw on top of a photo

Postby Natter » Tue May 11, 2021 11:45 am

Hi,

In TImage, I show photos. Can I draw something on top of a photo (for example, cross it out) ?
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: Draw on top of a photo

Postby ukoenig » Tue May 11, 2021 5:54 pm

Drawing lines on top of a image

Image

A sample

Code: Select all  Expand view  RUN

@ 450, 455 XIMAGE oImage3 SOURCE cBackImage  SIZE 130, 95 OF oFld1:aDialogs[ 2 ]
oImage3:nUserControl := 0 // disable actions
oImage3:lBmpTransparent := !(Lower( cFileExt( c_Path1 + cBackImage,  ) ) $ "jpg,jpeg") // disable transparent in JPG
oImage3:bChange := { || oImage3:lBmpTransparent := ;
    !(Lower( cFileExt( c_Path1 + cBackImage,  ) ) $ "jpg,jpeg"), ;
    oImage3:Refresh() }

//FREE_LINE(Object, hDC, nTop, nLeft, nBottom, nRight, nLineType, nColor, nPensize, nTransp )
oImage3:bPainted    := < |hDC|  
        FREE_LINE(oImage3, hDC, 10, 10, 80, 120, 1, 255, 8, 255 )
        FREE_LINE(oImage3, hDC, 10, 120, 80, 10, 1, 255, 8, 255 )
        RETURN NIL
>
...
...
// -------------- normal or glowing lines

FUNCTION FREE_LINE(Object, hDC, nTop, nLeft, nBottom, nRight, nLineType, nColor, nPensize, nTransp )
LOCAL oGraphics, oPen, nRed, nGreen, nBlue
LOCAL n, nPen
 
oGraphics       := Graphics():New( hDC )
nRed            := nRGBRed( nColor )
nGreen          := nRGBGreen( nColor )
nBlue           := nRGBBlue( nColor )

IF nLineType = 1        // line
        oPen            := Pen():New( nTransp, nRed, nGreen, nBlue, nPensize )
        oGraphics:DrawLine( oPen, nLeft, nTop, nRight, nBottom ) // oPen , nLeft, nTop, nRight, nBottom
ELSE                    // glow
        nPen               := nPensize * 0.5
        nTransp          := 255
        oPen               := Pen():New( nTransp, nRed, nGreen, nBlue, nPen )
         
        FOR n = 1 to 6
                oGraphics:DrawLine( oPen, nLeft, nTop, nRight, nBottom ) // oPen , nLeft, nTop, nRight, nBottom
                nTop    := nTop - nPen  
                nLeft   := nLeft - nPen  
                nRight  := nRight + 2 * nPen  
                nBottom := nBottom + 2 * nPen
                nTransp   := nTransp - 41
                oPen:setcolor( nTransp, nRed, nGreen, nBlue ) // transparent change
        NEXT    
ENDIF

oPen:Destroy()
oGraphics:Destroy()

RETURN NIL

 
Last edited by ukoenig on Wed May 12, 2021 4:59 am, 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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Draw on top of a photo

Postby Natter » Tue May 11, 2021 6:33 pm

Thanks, this is what I need !
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: Draw on top of a photo

Postby ukoenig » Wed May 12, 2021 5:00 am

I forgot to adjust the glow-effect-section ( 3D - look )

nlinetype 2 = glow
FREE_LINE(Object, hDC, nTop, nLeft, nBottom, nRight, nLineType, nColor, nPensize, nTransp )

the used values with calculated size ( 10 = the given distance from border )
Code: Select all  Expand view  RUN

oImage:bPainted    := < |hDC|  
        nHeight := oImage:nHeight - 20
        nWidth := oImage:nWidth - 10
        FREE_LINE(oImage, hDC, 10, 10, nHeight, nWidth, 2, 255, 4, 255 )
        FREE_LINE(oImage, hDC, 10, nWidth, nHeight, 10, 2, 255, 4, 255 )
//      FREE_LINE(oImage, hDC, 10, 10, 80, 120, 2, 255, 4, 255 )
//      FREE_LINE(oImage, hDC, 10, 120, 80, 10, 2, 255, 4, 255 )
        RETURN NIL
>
 


Image

another solution : optional to lines using a status-symbol on any place inside the image
Image
like

oImage:bPainted := < |hDC|
DRAW_IMG ( hDC, "Checkoff.bmp", { 10, 50, 30, 30 } )
RETURN NIL
>

for the moment just change the glow-section
Code: Select all  Expand view  RUN

IF nLineType = 1        // line
        oPen            := Pen():New( nTransp, nRed, nGreen, nBlue, nPensize )
        oGraphics:DrawLine( oPen, nLeft, nTop, nRight, nBottom ) // oPen , nLeft, nTop, nRight, nBottom
ELSE                    // glow
        nPen               := nPensize * 0.5
        nTransp          := 255
        oPen               := Pen():New( nTransp, nRed, nGreen, nBlue, nPen )
         
        FOR n = 1 to 6
                oGraphics:DrawLine( oPen, nLeft, nTop, nRight, nBottom ) // oPen , nLeft, nTop, nRight, nBottom
                nTop    := nTop + nPen  
                nBottom := nBottom + nPen
                nTransp   := nTransp - 41
                oPen:setcolor( nTransp, nRed, nGreen, nBlue ) // transparent change
        NEXT

 


regards
Uwe :D
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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 82 guests