I have modified the pixelcolor sample to check for pixels in a bitmap. How can I prevent to show the dialog ? With hide I get no correct result, so it seems that the dialog must be visible.
regards
Rudolf
Code: Select all
#INCLUDE "dll.CH"
#INCLUDE "dcdialog.CH"
#define CRLF chr(13) + CHR(10)
STATIC snHdll
FUNCTION Main()
******************************************************************
LOCAL GetList[0], GetOptions, oSay, hDC1, oStatic1, aPixel, oDlg
@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_BITMAP CAPTION "unterschrift1.bmp" OBJECT oStatic1 PREEVAL {|o|o:autoSize := .t.} ;
EVAL {|o|hDC1 := GetWindowDC(o:getHWnd()),aPixel := Array(o:caption:xSize,o:caption:ySize)}
DCGETOPTIONS PIXEL
DCREAD GUI FIT OPTIONS GetOptions EVAL {||dc_guimemoedit(testpixel(hDC1,aPixel,oStatic1,oSay))} PARENT @oDlg
oDlg:destroy()
RETURN nil
* ---------
FUNCTION testpixel(hDC,aPixel,oStatic)
******************************************************************
LOCAL i, j, nXSize := Len(aPixel), nYSize := Len(aPixel[1]),cCheck := "",nFilled := 0,oScrn,nFail := 0,nTotal := 0,aColor,nColor,nStartRow ,nEndRow,cResponse := "",nStartCol,nEndCol,cImg := "",cChar := " "
oScrn := DC_WaitOn()
nStartRow := 1 //int(nYSize/2) //only one row for testing
nEndRow := nYSize//int(nYSize/2)+1
nStartCol := 0
nEndCol := nXSize
FOR i := nStartCol TO nEndCol
FOR j := nStartRow to nEndRow
cChar := " "
nColor := GetPixel(hDC,i-1,j-1)
if !empty(nColor)
aColor := GraGetRGBIntensity(AutomationTranslateColor(nColor,.T.))
if valtype(aColor) = "A"
if aColor[1] # 255 .or. aColor[2] # 255 .or. aColor[3] # 255
nFilled++
cChar := "*"
endif
else
cChar := "?"
nFail++
cResponse += ntrim(i) + " - " + ntrim(j) + " " + ntrim(nColor) + CRLF
endif
nTotal++
else
cChar := "-"
endif
cImg += cChar
NEXT
cImg += CRLF
NEXT
dc_impl(oScrn)
cResponse := "Size:" + ntrim(nXSize) + "x" + ntrim(nYSize) + CRLF + "Total:" + ntrim(nTotal) + CRLF + "Fail:" + ntrim(nFail) + CRLF + "Filled:" + ntrim(nFilled) + CRLF + cImg
return cResponse
function ntrim(n)
******************************************************************
return rtrim(ltrim(str(n,10,0)))
* ---------
PROC appsys ; RETURN
* ---------
#command GDIFUNCTION <Func>([<x,...>]) ;
=> ;
FUNCTION <Func>([<x>]);;
STATIC scHCall := nil ;;
IF scHCall == nil ;;
IF snHdll == nil ;;
snHDll := DllLoad('GDI32.DLL') ;;
ENDIF ;;
scHCall := DllPrepareCall(snHDll,DLL_STDCALL,<(Func)>) ;;
ENDIF ;;
RETURN DllExecuteCall(scHCall,<x>)
GDIFUNCTION GetPixel( nHDC, x, y)
GDIFUNCTION SetPixel( nHDC, x, y, n )
DLLFUNCTION GetWindowDC( hwnd ) USING STDCALL FROM USER32.DLL