#include "fivewin.ch"
FUNCTION MAIN()
local cColori:="colori.png"
local cModello:="Modello.jpg"
local cFile:="da_colorare.jpg"
local oDlg,oBmp,oImg,oImgx
local nColor := 0, oColor
local hdc, nPickRow := 0, nPickCol := 0
local oSay1, oSay2, oSay3, oFont
local nColorSet:= 1
DEFINE CURSOR oHand HAND
DEFINE FONT oFont NAME "Verdanal" SIZE 0, -12 BOLD
DEFINE dialog oDlg size 1100, 500
@ 4,1 BITMAP oImgx filename cModello SIZE 270,200 OF oDlg PIXEL NOBORDER
@ 4,280 BITMAP oImg filename cFile SIZE 260,200 OF oDlg PIXEL NOBORDER
@ 210,260 BITMAP oBmp filename cColori SIZE 300,50 OF oDlg PIXEL NOBORDER
oImg:oCursor := oHand
oImg:bPainted := < |hDC|
oSay1:Refresh()
oSay2:Refresh()
oSay3:Refresh()
RETURN NIL
>
@ 210, 18 get oColor var ncolor size 20, 20 pixel COLOR nColor, nColor UPDATE NOBORDER
@ 210, 100 say oSay0 PROMPT "Top, Left, color" size 60, 30 pixel COLOR 0 FONT oFont UPDATE
@ 200, 210 say oSay1 var nPickRow size 20, 20 pixel COLOR 255 FONT oFont UPDATE
@ 210, 210 say oSay2 var nPickCol size 20, 20 pixel COLOR 255 FONT oFont UPDATE
@ 220, 210 say oSay3 var nColor size 20, 20 pixel COLOR 255 FONT oFont UPDATE
oBmp:oCursor := oHand
oBmp:bLClicked := { | nRow, nCol | ( ncolor := GETCOLOR( oBmp, nRow, nCol ), ;
oColor:SetColor(nColor, nColor), oColor:refresh(),nColorSet:=ncolor ) }
oImg:blClicked := { | nRow, nCol | nPickRow := nRow, nPickCol := nCol,;
FILLCOLOR(oImg, nPickRow, nPickCol, nColorSet ) }
ACTIVATE DIALOG oDlg CENTERED
oFont:End()
RETURN NIL
//-----------------------
FUNCTION GETCOLOR( oBmp, nRow, nCol )
hDC := oBmp:GetDC()
nColor := GetPixel( hDC, nCol, nRow )
oBmp:ReleaseDC()
RETURN nColor
//-----------------------
FUNCTION FILLCOLOR( oImg, nRow, nCol, nColor )
local hDC:=oImg:getDc()
LOCAL hBrush := CreateSolidBrush( nColor )
LOCAL hOld := SelectObject(hDC, hBrush)
ExtFloodFill(hDC, nCol, nRow,CLR_WHITE,2)
SelectObject( hDC, hOld )
DeleteObject( hBrush )
//FloodFill( hDC, nCol, nRow, nil, nColor )
oImg:ReleaseDC()
RETURN NIL