Sign in to follow this  
Followers 0
zwierzak

Clearing particular drawings with _GDIPlus_

7 posts in this topic

Hello,

I wonder if It's possible to clear particular drawings, withour clearing all of them - it would save some CPU usage while drawing. Redrawing all the lines(even when only few of them change their positions) is pointless. However, I don't know if it's possible.

Share this post


Link to post
Share on other sites



Don't think there is a direct way. But if you save your drawing(graphic) you can use that one to undo you next edit/change. (or use it as a general background image.)

Suggest you drop some relevant code to show what it is your doing. Might clarify things a bit.

Unless its related to your last topic. (is it?)


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

That is not possible but you can delete an area of your graphic screen when the object is not intersecting with other objects and the other objects are not moving!

It is like writing to a blackboard...

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Yes, It's kinda about it. However, I'm asking in gerenal, but u can use that code as well to show me any solution :x

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I made just as u adviced me to do. But u see, there is one problem. They're flickering far too much. Can u have a look on this example

#Include <GDIPlus.au3>
Opt("GUIOnEventMode", 1)

_GDIPlus_Startup()
$width = 800
$height = 200
$hGUI = GUICreate("GDI+", $width, $height)

$hPen = _GDIPlus_PenCreate(0xFFFF0000)
$eSize = 100
$x = $width

;Const
$hGraphicConst = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmapConst  = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphicConst)
$hBackbufferConst  = _GDIPlus_ImageGetGraphicsContext($hBitmapConst)
_GDIPlus_GraphicsSetSmoothingMode($hBackbufferConst, 2)
_GDIPlus_GraphicsDrawLine($hBackbufferConst, 0, 0, 100,50, $hPen)

;Changeable
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
_GDIPlus_GraphicsClear($hBackbuffer, 0xFFF0F0F0)
GUISetState()

GUISetOnEvent(-3, "_Exit")
While Sleep(40)
$pos = MouseGetPos()
    _GDIPlus_GraphicsClear($hBackbuffer, 0xFFF0F0F0)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, 0, 0, $pos[0], $pos[1], $hPen)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $width, $height)
    _GDIPlus_GraphicsDrawImageRect($hGraphicConst, $hBitmapConst, 0, 0, $width, $height)
WEnd

Func _Exit()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_BitmapDispose ($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc
Edited by zwierzak

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

They're flickering far too much.

If your refering to the screen. Drop in a WinSetTrans() after your GUICreate(). (for some older video cards.)

$hGUI = GUICreate("GDI+", $width, $height)
WinSetTrans($hGUI,"", 255) ;; (255 or -1)

If your refering to that odd line thats not doing anything. Drop(disable) that second *_DrawImageRect() line.

_GDIPlus_GraphicsDrawImageRect($hGraphicConst, $hBitmapConst, 0, 0, $width, $height)
See next msg. GDI+ always good for some ??? with me. :x

(WinSetTrans() trick of course also from UEZ :P )

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Try this:

#Include <GDIPlus.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2)

_GDIPlus_Startup()
$width = 800
$height = 200
$hGUI = GUICreate("GDI+", $width, $height)
$hGUI2 = GUICreate("", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_MDICHILD, $hGUI)
GUISetBkColor(0xF0F0F0, $hGUI2)
_WinAPI_SetLayeredWindowAttributes($hGUI2, 0xF0F0F0, 0xFF)
GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hGUI2)

$hPen = _GDIPlus_PenCreate(0xFFFF0000)
$eSize = 100
$x = $width

$hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($hGUI2)
_GDIPlus_GraphicsSetSmoothingMode($hGraphic2, 2)
_GDIPlus_GraphicsDrawLine($hGraphic2, 0, 0, 100,50, $hPen)

;Changeable
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
_GDIPlus_GraphicsClear($hBackbuffer, 0xFFF0F0F0)

GUISetOnEvent(-3, "_Exit")
While Sleep(40)
$pos = MouseGetPos()
    _GDIPlus_GraphicsClear($hBackbuffer, 0xFFF0F0F0)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, 0, 0, $pos[0], $pos[1], $hPen)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $width, $height)
WEnd

Func _Exit()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_BitmapDispose ($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI2)
    GUIDelete($hGUI)
    Exit
EndFunc

It uses 2 window layers for displaying the graphics. $hGraphic2 is the static one.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0