#include "Fivewin.ch"
#define SRCCOPY 13369376
FUNCTION MAIN()
LOCAL oDlg, oImg
DEFINE DIALOG oDlg;
SIZE 800, 600
@ 0, 0 IMAGE oImg;
SIZE 100, 100;
FILE "SFONDO.JPG";
ADJUST
@ 15, 0 BUTTON "Draw";
ACTION DRAWIMG( oImg )
@ 15, 20 BUTTON "Save";
ACTION oImg:SaveImage( "MYIMAGETEST.JPG", 2 )
ACTIVATE DIALOG oDlg;
CENTER
RETURN NIL
STATIC FUNCTION DRAWIMG( oImg )
LOCAL hDC := oImg:GetDC()
LOCAL nWidth := oImg:nWidth()
LOCAL nHeight := oImg:nHeight()
LOCAL hMemDC := CREATECOMPATIBLEDC( hDC )
LOCAL hMemBmp := CREATECOMPATIBLEBITMAP( hDC, nWidth, nHeight )
LOCAL hBmpOld := SELECTOBJECT( hMemDC, hMemBmp )
LOCAL hBitmap := oImg:hBitmap
LOCAL hPalette := oImg:hPalette
LOCAL x, y
PALBMPDRAW( hMemDC, 0, 0, hBitmap, hPalette, nWidth, nHeight )
FOR y = 0 TO 99
FOR x = 0 TO 159
SETPIXEL( hMemDC, x, y, CLR_HRED )
NEXT
NEXT
SELECTOBJECT( hMemDC, hBmpOld )
DELETEDC( hMemDC )
oImg:hBitmap = hMemBmp
PALBMPFREE( hBitmap, hPalette )
PALBMPNEW( oImg:hWnd, oImg:hBitmap, oImg:hPalette )
oImg:Refresh()
RETURN NIL
#include "Fivewin.ch"
#include "Image.ch"
#define SRCCOPY 13369376
FUNCTION MAIN()
LOCAL oDlg, oImg, hDC, oCbx1, oFont1
LOCAL oBtn1, oBtn2, oBtn3, oSay1, aSize := {}
LOCAL oTest, nOWidth, nOHeight, nPWidth, nPHeight, nResize
c_path := cFilePath(GetModuleFileName( GetInstance() ) )
c_path1 := c_path + "IMAGES\" // YOUR IMAGEPATH !!!!!
cWorkFile := c_path1 + "TEST.JPG"
cDestFile := "MYIMAGETEST"
nResize := 20
cResize := "20 %"
cExtension := "JPG"
DEFINE IMAGE oTest FILENAME cWorkfile
nOWidth := oTest:nWidth
nOHeight := oTest:nHeight
oTest:End()
nPWidth := nOWidth * ( nResize / 100 )
nPHeight := nOHeight * ( nResize / 100 )
DEFINE FONT oFont1 NAME "Arial" SIZE 0, -12 BOLD
DEFINE DIALOG oDlg SIZE 800, 600
@ 0, 0 IMAGE oImg FILENAME cWorkfile OF oDlg ;
SIZE nPWidth, nPHeight PIXEL NOBORDER ADJUST
@ 20, 350 BUTTON oBtn1 PROMPT "Draw" OF oDlg SIZE 40, 12 ;
ACTION DRAWIMG( oImg, hDC ) PIXEL
@ 50, 350 BUTTON oBtn2 PROMPT "Save"OF oDlg SIZE 40, 12 ;
ACTION oImg:SaveImage( c_path1 + "MYIMAGETEST.JPG", 2 ) PIXEL
@ 80, 350 BUTTON oBtn3 PROMPT "Show" OF oDlg SIZE 40, 12 ;
ACTION SHOWEXPORT(oDlg, c_path1 + "MYIMAGETEST.JPG", nPWidth, nPHeight ) PIXEL
@ 120, 350 SAY oSay1 PROMPT '% from original' SIZE 50,10 PIXEL FONT oFont1 OF oDlg
oSay1:Setcolor( 255, )
oSay1:lTransparent := .T.
n := 10
FOR I := 1 TO 30
AADD( aSize, { ALLTRIM(STR( n )) + " %", n } )
n := n + 5
NEXT
@ 130, 350 COMBOBOX oCbx1 VAR cResize ITEMS { aSize[1][1], aSize[2][1], aSize[3][1], ;
aSize[4][1], aSize[5][1], aSize[6][1], ;
aSize[7][1], aSize[8][1], aSize[9][1], ;
aSize[10][1], aSize[11][1], aSize[12][1], ;
aSize[13][1], aSize[14][1], aSize[15][1], ;
aSize[16][1], aSize[17][1], aSize[18][1], ;
aSize[19][1], aSize[20][1], aSize[21][1], ;
aSize[22][1], aSize[23][1], aSize[24][1], ;
aSize[25][1], aSize[26][1], aSize[27][1], ;
aSize[28][1], aSize[29][1], aSize[30][1] } ;
SIZE 42, 150 OF oDlg PIXEL FONT oFont1 ;
ON CHANGE ( nResize := aSize[oCbx1:nAt][2] + 4, ;
nPWidth := nOWidth * ( nResize / 100 ), ;
nPHeight := nOHeight * ( nResize / 100 ), ;
IIF( nPWidth < oDlg:nWidth - 40 .and. nPWidth < oDlg:nHeight - 10, ;
oImg:Move( 0, 0, nOWidth * ( nResize / 100 ), nOHeight * ( nResize / 100 ), .f. ), ;
MsgAlert( "Preview is oversized !!!", "Error" ) ), ;
oDlg:Refresh(), oImg:Refresh() )
@ 270, 350 BUTTON oBtn3 PROMPT "Exit" OF oDlg SIZE 40, 12 ;
ACTION oDlg:End() PIXEL
ACTIVATE DIALOG oDlg CENTER ;
ON INIT hDC := oImg:GetDC()
oFont1:End()
RETURN NIL
// -----------------
STATIC FUNCTION DRAWIMG( oImg, hDC )
//LOCAL hDC := oImg:GetDC()
LOCAL nWidth := oImg:nWidth()
LOCAL nHeight := oImg:nHeight()
LOCAL hMemDC := CREATECOMPATIBLEDC( hDC )
LOCAL hMemBmp := CREATECOMPATIBLEBITMAP( hDC, nWidth, nHeight )
LOCAL hBmpOld := SELECTOBJECT( hMemDC, hMemBmp )
LOCAL hBitmap := oImg:hBitmap
LOCAL hPalette := oImg:hPalette
PALBMPDRAW( hMemDC, 0, 0, hBitmap, hPalette, nWidth, nHeight )
DO_CALC( hMemDC )
SELECTOBJECT( hMemDC, hBmpOld )
DELETEDC( hMemDC )
oImg:hBitmap = hMemBmp
PALBMPFREE( hBitmap, hPalette )
PALBMPNEW( oImg:hWnd, oImg:hBitmap, oImg:hPalette )
oImg:Refresh()
RETURN NIL
// -------------------
STATIC FUNCTION DO_CALC( hMemDC )
LOCAL x, y
FOR y = 0 TO 99
FOR x = 0 TO 159
SETPIXEL( hMemDC, x, y, CLR_HRED )
NEXT
NEXT
RETURN NIL
// --------------------
STATIC FUNCTION SHOWEXPORT(oDlg, cDestFile, nPWidth, nPHeight)
LOCAL oDlg1, oTest, oBtn1
DEFINE DIALOG oDlg1 SIZE 800, 600 ;
TITLE c_path1 + "MYIMAGETEST.JPG" OF oDlg
@ 0, 0 IMAGE oTest SIZE 390, 260 OF oDlg1 SCROLL
oTest:Progress( .f. )
oTest:LoadBmp( c_path1 + "MYIMAGETEST.JPG" )
@ 270, 350 BUTTON oBtn1 PROMPT "Exit" OF oDlg1 SIZE 40, 12 ;
ACTION oDlg1:End() PIXEL
ACTIVATE DIALOG oDlg1 CENTER
oTest:End()
RETURN( NIL )
FOR y = 0 TO 1000
FOR x = 0 TO 1000
Enrico Maria Giordano wrote:Uwe, you paint an area that is too small. Try to paint an area of 1000 x 1000 and you will see the problem. I repeat what the problem is: I'd like to see the painted area gradually growing during the paint operation.
EMG
Function DrawOver( oImg )
Local x
Local y
For x = 10 to 50
//For y = 10 to 50
DrawImg( oImg, x )
SysWait( 0.009 )
//Next y
Next x
Return Nil
// Function Actual de Enrico
STATIC FUNCTION DRAWIMG( oImg, y )
LOCAL hDC := oImg:GetDC()
LOCAL nWidth := oImg:nWidth()
LOCAL nHeight := oImg:nHeight()
LOCAL hMemDC := CREATECOMPATIBLEDC( hDC )
LOCAL hMemBmp := CREATECOMPATIBLEBITMAP( hDC, nWidth, nHeight )
LOCAL hBmpOld := SELECTOBJECT( hMemDC, hMemBmp )
LOCAL hBitmap := oImg:hBitmap
LOCAL hPalette := oImg:hPalette
//LOCAL x, y
Local x
PALBMPDRAW( hMemDC, 0, 0, hBitmap, hPalette, nWidth, nHeight )
//FOR y = 10 TO 50
FOR x = 10 TO 50
SETPIXEL( hMemDC, x, y, CLR_HRED )
SysWait( 0.005 )
NEXT
//NEXT
SELECTOBJECT( hMemDC, hBmpOld )
DELETEDC( hMemDC )
oImg:hBitmap = hMemBmp
PALBMPFREE( hBitmap, hPalette )
PALBMPNEW( oImg:hWnd, oImg:hBitmap, oImg:hPalette )
oImg:Refresh()
RETURN NIL
//-----------------------------------------------------------------------------
ukoenig wrote:Enrico,
I used the maximum possible painting-area
with my used screenresolution of 1024 x 768
I coudn't find any problem.
STATIC FUNCTION DO_CALC( hMemDC )
LOCAL x, y
FOR y = 0 TO 1000
FOR x = 0 TO 1000
SETPIXEL( hMemDC, x, y, CLR_HRED )
NEXT
NEXT
RETURN NIL
cnavarro wrote:
- Code: Select all Expand view RUN
Function DrawOver( oImg )
Local x
Local y
For x = 10 to 50
//For y = 10 to 50
DrawImg( oImg, x )
SysWait( 0.009 )
//Next y
Next x
Return Nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 68 guests