UNDO the last action on imagepainting ?

UNDO the last action on imagepainting ?

Postby ukoenig » Fri Apr 11, 2014 11:21 am

Hello,

is it possible, a UNDO only for the last action on imagepainting ?
I can use oImg:Refresh(), but it clears the image and all paintings I have done before, are deleted as well.
All positions are defined with mouseclick top / left and bottom / right and calculated in relation to the original image-size.
I created this tool because doing all this with a commercial tool, many steps are needed and some options are not possible.
A solution would make it perfect.

NOTES : I ordered a extra NEW homepage. There I will place all tools and tips for download.

The drawing-options are called inside the function :

DRAWIMG( oDrawImg, hDC )
( The different values are define as STATIC )

Possible paintings on a image :

with any pensize and color :

Freehand
Line
Box
Fill


with selected font and color :

Date + Time stamp
Date stamp
Time stamp


using a resize-factor on :

Image-Logo
Transparent Logo ( with selected transparent-level )
Signature ( can be created inside the EXTRA-dialog)


Image

Maybe SAVING and RESTORING the last painting ?

Code: Select all  Expand view  RUN

// -----------------

STATIC FUNCTION DRAWIMG( oDrawImg, hDC )

LOCAL nWidth  := oDrawImg:nWidth()
LOCAL nHeight := oDrawImg:nHeight()
LOCAL hMemBmp, hBmpOld
LOCAL hBitmap  := oDrawImg:hBitmap
LOCAL hPalette := oDrawImg:hPalette

hMemDC := CREATECOMPATIBLEDC( hDC )
hMemBmp := CREATECOMPATIBLEBITMAP( hDC, nWidth, nHeight )
hBmpOld := SELECTOBJECT( hMemDC, hMemBmp )

PALBMPDRAW( hMemDC, 0, 0, hBitmap, hPalette, nWidth, nHeight )

// ------ STYLES -----------

IF cDrawStyle = "Freehand"
    DRAWPOINTS( hMemDC )
ENDIF
IF cDrawStyle = "Lines"
    CLICK_LINES( hMemDC )
ENDIF
IF cDrawStyle = "Box"
    CLICK_BOX( hMemDC )
ENDIF
IF cDrawStyle = "Fill"
    CLICK_FILL( hMemDC )
ENDIF
IF cDrawStyle = "Date + Time"
    CLICK_DT( hMemDC )
ENDIF
IF cDrawStyle = "Date"
    CLICK_DATE( hMemDC )
ENDIF
IF cDrawStyle = "Time"
    CLICK_TIME( hMemDC )
ENDIF
IF cDrawStyle = "Image-Logo"
    DRAW_IMAGE( hMemDC )
ENDIF
IF cDrawStyle = "Transp.Logo"
    DRAW_LOGO( hMemDC )
ENDIF

// -----------------

SELECTOBJECT( hMemDC, hBmpOld )
DELETEDC( hMemDC )
oDrawImg:hBitmap = hMemBmp
PALBMPFREE( hBitmap, hPalette )
PALBMPNEW( oDrawImg:hWnd, oDrawImg:hBitmap, oDrawImg:hPalette )

oDrawImg:Refresh()

RETURN NIL
 


Inside EXTRAS : define dialog-background, signature, date/timestamp-font and a resize-factor of a saved image

Image

Best regards
Uwe :?:
Last edited by ukoenig on Sat Apr 12, 2014 6:10 pm, edited 11 times 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: Undo last action on imagepainting ?

Postby pgfdz » Fri Apr 11, 2014 11:44 am

I think that you have to put into an array all actions and them paint each record.

local aActions := {}
aadd( aActions, {"image",10,10,300,200,"c:\myimage.bmp"} )
aadd( aActions, {"icon",200,200,32,32,"c:\myicon.ico"} )
....

for n := 1 to len( aActions )
PaintItems( aActions[n] )
next

You can select that items you want paint.

If you hold the elements in the array, you choose what to paint.

A greeting
Paco García
pgfdz
 
Posts: 145
Joined: Wed Nov 03, 2010 9:16 am

Re: UNDO the last action on imagepainting ?

Postby Massimo Linossi » Fri Apr 11, 2014 7:50 pm

You can save all the changes you make to a disk image numbered from 1 to n.
So you can go to a specific state.
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: UNDO the last action on imagepainting ?

Postby ukoenig » Fri Apr 11, 2014 8:42 pm

Paco, Massimo,

I tested, saving the image to a TEMP-file.
Now I is working like :

1.) I load the original
2.) I select from the combobox the drawing style.
3.) BEFORE I perform the painting-selection with a left mouseclick on the image,
-- I save the draw-status to a TEMP-file
4.) In case I don't like the new painting, I choose UNDO, loading the TEMP-file as workfile.
-- It could be done for a few steps, but one step back is enough.

CLEAR = delete ALL paintings
UNDO = delete last paintig ( restores TEMP.??? )

Image

Maybe I can work with MEMORY-functions :
FI_LoadFromMemory(
FI_CloseMemory(
FI_SaveToMemory(


I'm calling the drawing function with :

STATIC FUNCTION DRAWIMG( oDrawImg, hDC, x, y, lPaint )

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.
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: Google [Bot] and 46 guests