|
From: Raphael S. <win...@ra...> - 2009-03-09 00:06:51
|
Hi @ all
I try to plot a static DC-Object (means: the graphic is calculated uniquely
at runtime, depending of several parameters, and does not change while
displaying the window) in a window.
The problem is that this object continuously needs to be redrawn, because it
vanishes during moving the window around, or if an other window is moving
over it.
I thought, a repaint-routine like that would solve the problem:
-------------------------------------
use strict;
use Win32::GUI();
our $WIN;
our %DC;
&build_gui;
Win32::GUI::Dialog();
sub build_gui # Building the GUI
{
$WIN = new Win32::GUI::Window(
-left => 200, -top => 200, -width => 300, -height => 300,
-name => "WIN",
-text => "Static-DC-Test",
#-noflicker => 1, # Useless/worse result
);
$WIN->Show();
$DC{'color'}{'white'} = [255,255,255];
$DC{'color'}{'red'} = [255,0,0];
$DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width =>
3, );
$DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'},
-width => 1, );
&repaint;
$DC{'timer'} = $WIN ->AddTimer("timer", 100);
}
sub ::timer_Timer # Repaint DC with interval of 'timer'
{ &repaint; }
sub WIN_Terminate { return -1; }
sub repaint # Create/rebuild DC-Object
{
$DC{'dc'}{'object'} = $WIN -> GetDC;
$DC{'dc'}{'object'} -> FillRect(10, 10, 280, 260,$DC{'brush'});
$DC{'dc'}{'object'} -> SelectObject($DC{'pen'});
$DC{'dc'}{'object'} -> BeginPath();
$DC{'dc'}{'object'} -> MoveTo(10, 10);
$DC{'dc'}{'object'} -> LineTo(280, 260);
$DC{'dc'}{'object'} -> EndPath();
$DC{'dc'}{'object'} -> StrokePath();
#$DC{'dc'}{'object'} -> Save(); # ??? Save() --> Restore() ???
}
-------------------------------------
But the result of the code above is a flickering, annoying graphic.
So the next thought, was to generate a bitmap from the DC. There is, if Im
not wrong, a method with DIBitmap. But, I would like to refrain from binding
in that module, only for converting a single graphic, because its bloating
up the program/PAR-binary.
Sadly, the DC-Documentation is frequent a sealed book for me.
Does anyone know an easy method (I also like to take a complex solution :-))
to convert a DC into a bitmap-object, without using DIBitmap? Or, even
better, a way to prevent that flickering during the repaint?
Thanks a lot.
Regards,
Raphael
|
|
From: Jason P. <ma...@wa...> - 2009-03-09 09:27:15
|
Hello Raphael,
I unfortunately do not have a breadth of experience with the DC object as
some on this list, but having seen this I can at least offer some tid-bit of
possible use. I would say that the one means I can come to think of is
ignoring repaint wherein there is no cause to redraw this particular
rectangle. Ok, this sounds a simple concept, but I realize this may not be
as easy to complete in reality. This of course, offers no help with the
issue of the bad flicker during dragging, but it offers some to the regular
usage flickering.
Jason P
On Sun, Mar 8, 2009 at 7:54 PM, Raphael Stoeckli <win...@ra...>wrote:
> Hi @ all
>
> I try to plot a static DC-Object (means: the graphic is calculated uniquely
> at runtime, depending of several parameters, and does not change while
> displaying the window) in a window.
> The problem is that this object continuously needs to be redrawn, because
> it
> vanishes during moving the window around, or if an other window is moving
> over it.
> I thought, a repaint-routine like that would solve the problem:
> -------------------------------------
> use strict;
> use Win32::GUI();
> our $WIN;
> our %DC;
>
> &build_gui;
> Win32::GUI::Dialog();
>
> sub build_gui # Building the GUI
> {
> $WIN = new Win32::GUI::Window(
> -left => 200, -top => 200, -width => 300, -height => 300,
> -name => "WIN",
> -text => "Static-DC-Test",
> #-noflicker => 1, # Useless/worse result
> );
> $WIN->Show();
> $DC{'color'}{'white'} = [255,255,255];
> $DC{'color'}{'red'} = [255,0,0];
> $DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width =>
> 3, );
> $DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'},
> -width => 1, );
> &repaint;
> $DC{'timer'} = $WIN ->AddTimer("timer", 100);
> }
>
> sub ::timer_Timer # Repaint DC with interval of 'timer'
> { &repaint; }
>
> sub WIN_Terminate { return -1; }
>
> sub repaint # Create/rebuild DC-Object
> {
> $DC{'dc'}{'object'} = $WIN -> GetDC;
> $DC{'dc'}{'object'} -> FillRect(10, 10, 280, 260,$DC{'brush'});
> $DC{'dc'}{'object'} -> SelectObject($DC{'pen'});
> $DC{'dc'}{'object'} -> BeginPath();
> $DC{'dc'}{'object'} -> MoveTo(10, 10);
> $DC{'dc'}{'object'} -> LineTo(280, 260);
> $DC{'dc'}{'object'} -> EndPath();
> $DC{'dc'}{'object'} -> StrokePath();
> #$DC{'dc'}{'object'} -> Save(); # ??? Save() --> Restore() ???
> }
> -------------------------------------
> But the result of the code above is a flickering, annoying graphic.
> So the next thought, was to generate a bitmap from the DC. There is, if I’m
> not wrong, a method with DIBitmap. But, I would like to refrain from
> binding
> in that module, only for converting a single graphic, because it’s bloating
> up the program/PAR-binary.
>
>
> Sadly, the DC-Documentation is frequent a sealed book for me.
> Does anyone know an easy method (I also like to take a complex solution
> :-))
> to convert a DC into a bitmap-object, without using DIBitmap? Or, even
> better, a way to prevent that flickering during the repaint?
>
> Thanks a lot.
>
> Regards,
> Raphael
>
>
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
> CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
> Enterprise
> -Strategies to boost innovation and cut costs with open source
> participation
> -Receive a $600 discount off the registration fee with the source code:
> SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Per...@li...
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
>
--
Maximus*
WarheadsSE
MaxSource
|
|
From: Jeremy W. <jez...@ho...> - 2009-03-09 18:39:40
|
Hi Raphael,
I don't have Win32::GUI in front of me - but:
You always need Validate, as this tells windows that you have finished drawing for the paint event. Drawing to a "live" DC will always be slow and flickery. You need to draw to a memory DC and bitblit the result to the window DC - I think there is an example of this in the examples that comes with Win32::GUI.
Cheers,
Jeremy.
> From: win...@ra...
> To: ma...@wa...
> Date: Mon, 9 Mar 2009 12:22:02 +0100
> CC: per...@li...
> Subject: Re: [perl-win32-gui-users] flickering static-DC
>
> Hi Jason
>
> Thanks for the fast response.
> Serendipitously I found a usable solution for the problem, just some minutes
> ago.
> There is a window-event called Paint, with the mysterious description "Sent
> when the window needs to be repainted."
> Here is the updated code:
>
> -------------------------------------
> use strict;
> use Win32::GUI();
> our $WIN;
> our %DC;
>
> &build_gui;
> Win32::GUI::Dialog();
>
> sub build_gui # Building the GUI
> {
> $WIN = new Win32::GUI::Window(
> -left => 200, -top => 200, -width => 300, -height => 300,
> -name => "WIN",
> -text => "Static-DC-Test v2",
> #-noflicker => 1, # Will not work with the Paint-event
> );
> $WIN->Show();
> $DC{'color'}{'white'} = [255,255,255];
> $DC{'color'}{'red'} = [255,0,0];
> $DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width =>
> 3, );
> $DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'},
> -width => 1, );
> &repaint;
> }
>
> sub WIN_Terminate { return -1; }
>
> sub WIN_Paint # re-/paint-event of the window
> {
> #my $DC = shift; # seems to be no need for this (in that case?)
> &repaint;
> }
>
> sub repaint # Create/rebuild DC-Object
> {
> $DC{'dc'}{'object'} = $WIN -> GetDC;
> $DC{'dc'}{'object'} -> FillRect(10, 10, 280, 260,$DC{'brush'});
> $DC{'dc'}{'object'} -> SelectObject($DC{'pen'});
> $DC{'dc'}{'object'} -> BeginPath();
> $DC{'dc'}{'object'} -> MoveTo(10, 10);
> $DC{'dc'}{'object'} -> LineTo(280, 260);
> $DC{'dc'}{'object'} -> EndPath();
> $DC{'dc'}{'object'} -> StrokePath();
> # $DC{'dc'}{'object'} -> Validate(); # seems to be no need for this (in that
> case?)
> }
> -------------------------------------
>
> Flickering is reduced to the times, when an other window moves over the
> DC-window, (or the DC-window is resizing). But in my case that's not very
> annoying. What I'm not getting at the moment is the thing with Validate() of
> the DC (seems nothing to do), or if there is a more efficient way to draw
> the DC.
>
> Nevertheless I hope, I can help other people with the example above.
>
> Greetings,
> Raphael
>
> ________________________________________
> Von: Jason Plum [mailto:max@.....net]
> Gesendet: Montag, 9. März 2009 10:02
> An: Raphael Stoeckli
> Cc: per...@li...
> Betreff: Re: [perl-win32-gui-users] flickering static-DC
>
> Hello Raphael,
>
> I unfortunately do not have a breadth of experience with the DC object as
> some on this list, but having seen this I can at least offer some tid-bit of
> possible use. I would say that the one means I can come to think of is
> ignoring repaint wherein there is no cause to redraw this particular
> rectangle. Ok, this sounds a simple concept, but I realize this may not be
> as easy to complete in reality. This of course, offers no help with the
> issue of the bad flicker during dragging, but it offers some to the regular
> usage flickering.
>
>
> Jason P
> On Sun, Mar 8, 2009 at 7:54 PM, Raphael Stoeckli <win32gui@.....ch> wrote:
> Hi @ all
>
> I try to plot a static DC-Object (means: the graphic is calculated uniquely
> at runtime, depending of several parameters, and does not change while
> displaying the window) in a window.
> The problem is that this object continuously needs to be redrawn, because it
> vanishes during moving the window around, or if an other window is moving
> over it.
> I thought, a repaint-routine like that would solve the problem:
> -------------------------------------
> use strict;
> use Win32::GUI();
> our $WIN;
> our %DC;
>
> &build_gui;
> Win32::GUI::Dialog();
>
> sub build_gui # Building the GUI
> {
> $WIN = new Win32::GUI::Window(
> -left => 200, -top => 200, -width => 300, -height => 300,
> -name => "WIN",
> -text => "Static-DC-Test",
> #-noflicker => 1, # Useless/worse result
> );
> $WIN->Show();
> $DC{'color'}{'white'} = [255,255,255];
> $DC{'color'}{'red'} = [255,0,0];
> $DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width =>
> 3, );
> $DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'},
> -width => 1, );
> &repaint;
> $DC{'timer'} = $WIN ->AddTimer("timer", 100);
> }
>
> sub ::timer_Timer # Repaint DC with interval of 'timer'
> { &repaint; }
>
> sub WIN_Terminate { return -1; }
>
> sub repaint # Create/rebuild DC-Object
> {
> $DC{'dc'}{'object'} = $WIN -> GetDC;
> $DC{'dc'}{'object'} -> FillRect(10, 10, 280, 260,$DC{'brush'});
> $DC{'dc'}{'object'} -> SelectObject($DC{'pen'});
> $DC{'dc'}{'object'} -> BeginPath();
> $DC{'dc'}{'object'} -> MoveTo(10, 10);
> $DC{'dc'}{'object'} -> LineTo(280, 260);
> $DC{'dc'}{'object'} -> EndPath();
> $DC{'dc'}{'object'} -> StrokePath();
> #$DC{'dc'}{'object'} -> Save(); # ??? Save() --> Restore() ???
> }
> -------------------------------------
> But the result of the code above is a flickering, annoying graphic.
> So the next thought, was to generate a bitmap from the DC. There is, if I’m
> not wrong, a method with DIBitmap. But, I would like to refrain from binding
> in that module, only for converting a single graphic, because it’s bloating
> up the program/PAR-binary.
>
>
> Sadly, the DC-Documentation is frequent a sealed book for me.
> Does anyone know an easy method (I also like to take a complex solution :-))
> to convert a DC into a bitmap-object, without using DIBitmap? Or, even
> better, a way to prevent that flickering during the repaint?
>
> Thanks a lot.
>
> Regards,
> Raphael
>
>
> ----------------------------------------------------------------------------
> --
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Per...@li...
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
>
>
>
> --
> Maximus*
> WarheadsSE
> MaxSource
>
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Per...@li...
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
_________________________________________________________________
25GB of FREE Online Storage – Find out more
http://clk.atdmt.com/UKM/go/134665320/direct/01/ |
|
From: Raphael S. <win...@ra...> - 2009-03-09 20:51:02
|
Hi Jeremy
I noticed that with Validate() in the meanwhile. The flickering came back as
I added more DC-elements. A terminating
$DC{'dc'}{'object'} -> Validate(); # (Uncommented this at line 43 of the
example)
stopped further flickering, respectively endless repaint. My example was
probably a little bit too simple.
Big question mark is still that:
WIN_Paint
{ my $dc = shift; # <-- ???
}
I don't need that. Is my code working without an assigned parameter, because
my DC-Object is global? The Validate() happens in my example-sub repaint{}.
But it's probably the wrong approach (see section below).
As to the performance:
As you said, in the examples BitmapScroll.pl and Region.pl is BitBlt used. I
will look into them. Well, thanks for this hint. Concerning to function
describing, the DC-documentation is, let me say
a little bit minimalist.
Thanks a lot.
Greetings, Raphael
________________________________________
Von: Jeremy White [mailto:jez_white@.....com]
Gesendet: Montag, 9. März 2009 19:39
An: win32gui@.....ch; max@.....net
Cc: per...@li...
Betreff: RE: [perl-win32-gui-users] flickering static-DC
Hi Raphael,
I don't have Win32::GUI in front of me - but:
You always need Validate, as this tells windows that you have finished
drawing for the paint event. Drawing to a "live" DC will always be slow and
flickery. You need to draw to a memory DC and bitblit the result to the
window DC - I think there is an example of this in the examples that comes
with Win32::GUI.
Cheers,
Jeremy.
> From: win32gui@.....ch
> To: ma...@wa...
> Date: Mon, 9 Mar 2009 12:22:02 +0100
> CC: per...@li...
> Subject: Re: [perl-win32-gui-users] flickering static-DC
>
> Hi Jason
>
> Thanks for the fast response.
> Serendipitously I found a usable solution for the problem, just some
minutes
> ago.
> There is a window-event called Paint, with the mysterious description
"Sent
> when the window needs to be repainted."
> Here is the updated code:
>
> -------------------------------------
> use strict;
> use Win32::GUI();
> our $WIN;
> our %DC;
>
> &build_gui;
> Win32::GUI::Dialog();
>
> sub build_gui # Building the GUI
> {
> $WIN = new Win32::GUI::Window(
> -left => 200, -top => 200, -width => 300, -height => 300,
> -name => "WIN",
> -text => "Static-DC-Test v2",
> #-noflicker => 1, # Will not work with the Paint-event
> );
> $WIN->Show();
> $DC{'color'}{'white'} = [255,255,255];
> $DC{'color'}{'red'} = [255,0,0];
> $DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width =>
> 3, );
> $DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'},
> -width => 1, );
> &repaint;
> }
>
> sub WIN_Terminate { return -1; }
>
> sub WIN_Paint # re-/paint-event of the window
> {
> #my $DC = shift; # seems to be no need for this (in that case?)
> &repaint;
> }
>
> sub repaint # Create/rebuild DC-Object
> {
> $DC{'dc'}{'object'} = $WIN -> GetDC;
> $DC{'dc'}{'object'} -> FillRect(10, 10, 280, 260,$DC{'brush'});
> $DC{'dc'}{'object'} -> SelectObject($DC{'pen'});
> $DC{'dc'}{'object'} -> BeginPath();
> $DC{'dc'}{'object'} -> MoveTo(10, 10);
> $DC{'dc'}{'object'} -> LineTo(280, 260);
> $DC{'dc'}{'object'} -> EndPath();
> $DC{'dc'}{'object'} -> StrokePath();
> # $DC{'dc'}{'object'} -> Validate(); # seems to be no need for this (in
that
> case?)
> }
> -------------------------------------
>
> Flickering is reduced to the times, when an other window moves over the
> DC-window, (or the DC-window is resizing). But in my case that's not very
> annoying. What I'm not getting at the moment is the thing with Validate()
of
> the DC (seems nothing to do), or if there is a more efficient way to draw
> the DC.
>
> Nevertheless I hope, I can help other people with the example above.
>
> Greetings,
> Raphael
>
> ________________________________________
> Von: Jason Plum [mailto:max@.....net]
> Gesendet: Montag, 9. März 2009 10:02
> An: Raphael Stoeckli
> Cc: per...@li...
> Betreff: Re: [perl-win32-gui-users] flickering static-DC
>
> Hello Raphael,
>
> I unfortunately do not have a breadth of experience with the DC object as
> some on this list, but having seen this I can at least offer some tid-bit
of
> possible use. I would say that the one means I can come to think of is
> ignoring repaint wherein there is no cause to redraw this particular
> rectangle. Ok, this sounds a simple concept, but I realize this may not be
> as easy to complete in reality. This of course, offers no help with the
> issue of the bad flicker during dragging, but it offers some to the
regular
> usage flickering.
>
>
> Jason P
> On Sun, Mar 8, 2009 at 7:54 PM, Raphael Stoeckli <win32gui@.....ch> wrote:
> Hi @ all
>
> I try to plot a static DC-Object (means: the graphic is calculated
uniquely
> at runtime, depending of several parameters, and does not change while
> displaying the window) in a window.
> The problem is that this object continuously needs to be redrawn, because
it
> vanishes during moving the window around, or if an other window is moving
> over it.
> I thought, a repaint-routine like that would solve the problem:
> -------------------------------------
> use strict;
> use Win32::GUI();
> our $WIN;
> our %DC;
>
> &build_gui;
> Win32::GUI::Dialog();
>
> sub build_gui # Building the GUI
> {
> $WIN = new Win32::GUI::Window(
> -left => 200, -top => 200, -width => 300, -height => 300,
> -name => "WIN",
> -text => "Static-DC-Test",
> #-noflicker => 1, # Useless/worse result
> );
> $WIN->Show();
> $DC{'color'}{'white'} = [255,255,255];
> $DC{'color'}{'red'} = [255,0,0];
> $DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width =>
> 3, );
> $DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'},
> -width => 1, );
> &repaint;
> $DC{'timer'} = $WIN ->AddTimer("timer", 100);
> }
>
> sub ::timer_Timer # Repaint DC with interval of 'timer'
> { &repaint; }
>
> sub WIN_Terminate { return -1; }
>
> sub repaint # Create/rebuild DC-Object
> {
> $DC{'dc'}{'object'} = $WIN -> GetDC;
> $DC{'dc'}{'object'} -> FillRect(10, 10, 280, 260,$DC{'brush'});
> $DC{'dc'}{'object'} -> SelectObject($DC{'pen'});
> $DC{'dc'}{'object'} -> BeginPath();
> $DC{'dc'}{'object'} -> MoveTo(10, 10);
> $DC{'dc'}{'object'} -> LineTo(280, 260);
> $DC{'dc'}{'object'} -> EndPath();
> $DC{'dc'}{'object'} -> StrokePath();
> #$DC{'dc'}{'object'} -> Save(); # ??? Save() --> Restore() ???
> }
> -------------------------------------
> But the result of the code above is a flickering, annoying graphic.
> So the next thought, was to generate a bitmap from the DC. There is, if
Im
> not wrong, a method with DIBitmap. But, I would like to refrain from
binding
> in that module, only for converting a single graphic, because its
bloating
> up the program/PAR-binary.
>
>
> Sadly, the DC-Documentation is frequent a sealed book for me.
> Does anyone know an easy method (I also like to take a complex solution
:-))
> to convert a DC into a bitmap-object, without using DIBitmap? Or, even
> better, a way to prevent that flickering during the repaint?
>
> Thanks a lot.
>
> Regards,
> Raphael
>
>
>
----------------------------------------------------------------------------
> --
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
Enterprise
> -Strategies to boost innovation and cut costs with open source
participation
> -Receive a $600 discount off the registration fee with the source code:
SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Per...@li...
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
>
>
>
> --
> Maximus*
> WarheadsSE
> MaxSource
>
>
>
----------------------------------------------------------------------------
--
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
Enterprise
> -Strategies to boost innovation and cut costs with open source
participation
> -Receive a $600 discount off the registration fee with the source code:
SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Per...@li...
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
________________________________________
Share your photos with Windows Live Photos Free. Try it Now!
|
|
From: Raphael S. <win...@ra...> - 2009-03-09 11:20:15
|
Hi Jason
Thanks for the fast response.
Serendipitously I found a usable solution for the problem, just some minutes
ago.
There is a window-event called Paint, with the mysterious description "Sent
when the window needs to be repainted."
Here is the updated code:
-------------------------------------
use strict;
use Win32::GUI();
our $WIN;
our %DC;
&build_gui;
Win32::GUI::Dialog();
sub build_gui # Building the GUI
{
$WIN = new Win32::GUI::Window(
-left => 200, -top => 200, -width => 300, -height => 300,
-name => "WIN",
-text => "Static-DC-Test v2",
#-noflicker => 1, # Will not work with the Paint-event
);
$WIN->Show();
$DC{'color'}{'white'} = [255,255,255];
$DC{'color'}{'red'} = [255,0,0];
$DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width =>
3, );
$DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'},
-width => 1, );
&repaint;
}
sub WIN_Terminate { return -1; }
sub WIN_Paint # re-/paint-event of the window
{
#my $DC = shift; # seems to be no need for this (in that case?)
&repaint;
}
sub repaint # Create/rebuild DC-Object
{
$DC{'dc'}{'object'} = $WIN -> GetDC;
$DC{'dc'}{'object'} -> FillRect(10, 10, 280, 260,$DC{'brush'});
$DC{'dc'}{'object'} -> SelectObject($DC{'pen'});
$DC{'dc'}{'object'} -> BeginPath();
$DC{'dc'}{'object'} -> MoveTo(10, 10);
$DC{'dc'}{'object'} -> LineTo(280, 260);
$DC{'dc'}{'object'} -> EndPath();
$DC{'dc'}{'object'} -> StrokePath();
# $DC{'dc'}{'object'} -> Validate(); # seems to be no need for this (in that
case?)
}
-------------------------------------
Flickering is reduced to the times, when an other window moves over the
DC-window, (or the DC-window is resizing). But in my case that's not very
annoying. What I'm not getting at the moment is the thing with Validate() of
the DC (seems nothing to do), or if there is a more efficient way to draw
the DC.
Nevertheless I hope, I can help other people with the example above.
Greetings,
Raphael
________________________________________
Von: Jason Plum [mailto:max@.....net]
Gesendet: Montag, 9. März 2009 10:02
An: Raphael Stoeckli
Cc: per...@li...
Betreff: Re: [perl-win32-gui-users] flickering static-DC
Hello Raphael,
I unfortunately do not have a breadth of experience with the DC object as
some on this list, but having seen this I can at least offer some tid-bit of
possible use. I would say that the one means I can come to think of is
ignoring repaint wherein there is no cause to redraw this particular
rectangle. Ok, this sounds a simple concept, but I realize this may not be
as easy to complete in reality. This of course, offers no help with the
issue of the bad flicker during dragging, but it offers some to the regular
usage flickering.
Jason P
On Sun, Mar 8, 2009 at 7:54 PM, Raphael Stoeckli <win32gui@.....ch> wrote:
Hi @ all
I try to plot a static DC-Object (means: the graphic is calculated uniquely
at runtime, depending of several parameters, and does not change while
displaying the window) in a window.
The problem is that this object continuously needs to be redrawn, because it
vanishes during moving the window around, or if an other window is moving
over it.
I thought, a repaint-routine like that would solve the problem:
-------------------------------------
use strict;
use Win32::GUI();
our $WIN;
our %DC;
&build_gui;
Win32::GUI::Dialog();
sub build_gui # Building the GUI
{
$WIN = new Win32::GUI::Window(
-left => 200, -top => 200, -width => 300, -height => 300,
-name => "WIN",
-text => "Static-DC-Test",
#-noflicker => 1, # Useless/worse result
);
$WIN->Show();
$DC{'color'}{'white'} = [255,255,255];
$DC{'color'}{'red'} = [255,0,0];
$DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width =>
3, );
$DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'},
-width => 1, );
&repaint;
$DC{'timer'} = $WIN ->AddTimer("timer", 100);
}
sub ::timer_Timer # Repaint DC with interval of 'timer'
{ &repaint; }
sub WIN_Terminate { return -1; }
sub repaint # Create/rebuild DC-Object
{
$DC{'dc'}{'object'} = $WIN -> GetDC;
$DC{'dc'}{'object'} -> FillRect(10, 10, 280, 260,$DC{'brush'});
$DC{'dc'}{'object'} -> SelectObject($DC{'pen'});
$DC{'dc'}{'object'} -> BeginPath();
$DC{'dc'}{'object'} -> MoveTo(10, 10);
$DC{'dc'}{'object'} -> LineTo(280, 260);
$DC{'dc'}{'object'} -> EndPath();
$DC{'dc'}{'object'} -> StrokePath();
#$DC{'dc'}{'object'} -> Save(); # ??? Save() --> Restore() ???
}
-------------------------------------
But the result of the code above is a flickering, annoying graphic.
So the next thought, was to generate a bitmap from the DC. There is, if Im
not wrong, a method with DIBitmap. But, I would like to refrain from binding
in that module, only for converting a single graphic, because its bloating
up the program/PAR-binary.
Sadly, the DC-Documentation is frequent a sealed book for me.
Does anyone know an easy method (I also like to take a complex solution :-))
to convert a DC into a bitmap-object, without using DIBitmap? Or, even
better, a way to prevent that flickering during the repaint?
Thanks a lot.
Regards,
Raphael
----------------------------------------------------------------------------
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Perl-Win32-GUI-Users mailing list
Per...@li...
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/
--
Maximus*
WarheadsSE
MaxSource
|
|
From: zak3 <zak...@gm...> - 2009-03-09 11:57:04
|
Hi also look to this link about drawing and refreshing: http://www.nabble.com/Draw-on-click-and-refresh-the-window---resolved-td18093899.html and the two tutorials by rob may about drawing and refreshing: http://www.mail-archive.com/per...@li.../msg05194.html http://www.mail-archive.com/per...@li.../msg05195.html also before three days i have found an example in the win32gui demos : demos\DIBitmap\ the first is test8.pl and test13.pl they draw a circle without any flickering, they use GD graphics with DIBitmap, first install GD Graphics from this site:http://www.bribes.org/perl/ppmdir.html using the command: ppm install http://www.bribes.org/perl/ppm/GD.ppd and try the test8.pl and test13.pl, the GD graphics have many plotting statements for drawing lines, polygons, points, etc Raphael Stoeckli wrote: > > Hi @ all > > I try to plot a static DC-Object (means: the graphic is calculated > uniquely > at runtime, depending of several parameters, and does not change while > displaying the window) in a window. > The problem is that this object continuously needs to be redrawn, because > it > vanishes during moving the window around, or if an other window is moving > over it. > I thought, a repaint-routine like that would solve the problem: > ------------------------------------- > use strict; > use Win32::GUI(); > our $WIN; > our %DC; > > &build_gui; > Win32::GUI::Dialog(); > > sub build_gui # Building the GUI > { > $WIN = new Win32::GUI::Window( > -left => 200, -top => 200, -width => 300, -height => 300, > -name => "WIN", > -text => "Static-DC-Test", > #-noflicker => 1, # Useless/worse result > ); > $WIN->Show(); > $DC{'color'}{'white'} = [255,255,255]; > $DC{'color'}{'red'} = [255,0,0]; > $DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width => > 3, ); > $DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'}, > -width => 1, ); > &repaint; > $DC{'timer'} = $WIN ->AddTimer("timer", 100); > } > > sub ::timer_Timer # Repaint DC with interval of 'timer' > { &repaint; } > > sub WIN_Terminate { return -1; } > > sub repaint # Create/rebuild DC-Object > { > $DC{'dc'}{'object'} = $WIN -> GetDC; > $DC{'dc'}{'object'} -> FillRect(10, 10, 280, 260,$DC{'brush'}); > $DC{'dc'}{'object'} -> SelectObject($DC{'pen'}); > $DC{'dc'}{'object'} -> BeginPath(); > $DC{'dc'}{'object'} -> MoveTo(10, 10); > $DC{'dc'}{'object'} -> LineTo(280, 260); > $DC{'dc'}{'object'} -> EndPath(); > $DC{'dc'}{'object'} -> StrokePath(); > #$DC{'dc'}{'object'} -> Save(); # ??? Save() --> Restore() ??? > } > ------------------------------------- > But the result of the code above is a flickering, annoying graphic. > So the next thought, was to generate a bitmap from the DC. There is, if > Im > not wrong, a method with DIBitmap. But, I would like to refrain from > binding > in that module, only for converting a single graphic, because its > bloating > up the program/PAR-binary. > > > Sadly, the DC-Documentation is frequent a sealed book for me. > Does anyone know an easy method (I also like to take a complex solution > :-)) > to convert a DC into a bitmap-object, without using DIBitmap? Or, even > better, a way to prevent that flickering during the repaint? > > Thanks a lot. > > Regards, > Raphael > > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, > CA > -OSBC tackles the biggest issue in open source: Open Sourcing the > Enterprise > -Strategies to boost innovation and cut costs with open source > participation > -Receive a $600 discount off the registration fee with the source code: > SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > > -- View this message in context: http://www.nabble.com/flickering-static-DC-tp22404906p22411762.html Sent from the perl-win32-gui-users mailing list archive at Nabble.com. |
|
From: Raphael S. <win...@ra...> - 2009-03-10 23:51:38
|
Hi Zak I run probably an old version of ASPerl (5.8.6.811). There is an error, when I try to run test8.pl or test13.pl. Hook Perl_newXS_flags was not found in perl58.dll. I think, I remained on 5.8.6.811, because of some PAR-compatibility-issues (most likely obsolote now). I will try it on an other machine with 5.8.8 or 5.10 the next days. My program works now pretty good, without much flickering, only with win32-GUI-corefunctions. I will also try to move my window-DC into a memory-DC the next days, as I said in my last post. I will post some sample-code when I finished that. To tell the truth, DIBitmap and GD frighten me a little bit. Is not that I don't understand it already worked with DIBitmap intensively. But my program will be a standalone-binary for PCs without Perl. Even though 1TB-HDDs are on the advance, I am still skeptic if I have a binary of more than 3 or 4 MB in front of me, to run a really simple program. Maybe I am too conservative :-) Anyhow, much thanks for your hint. I will also study the two posts from mail-archive.com. Greetings, Raphael -----Ursprüngliche Nachricht----- Von: zak3 [mailto:zak31415@.....com] Gesendet: Montag, 9. März 2009 12:57 An: per...@li... Betreff: Re: [perl-win32-gui-users] flickering static-DC Hi also look to this link about drawing and refreshing: http://www.nabble.com/Draw-on-click-and-refresh-the-window---resolved-td1809 3899.html and the two tutorials by rob may about drawing and refreshing: http://www.mail-archive.com/per...@li.../msg05 194.html http://www.mail-archive.com/per...@li.../msg05 195.html also before three days i have found an example in the win32gui demos : demos\DIBitmap\ the first is test8.pl and test13.pl they draw a circle without any flickering, they use GD graphics with DIBitmap, first install GD Graphics from this site:http://www.bribes.org/perl/ppmdir.html using the command: ppm install http://www.bribes.org/perl/ppm/GD.ppd and try the test8.pl and test13.pl, the GD graphics have many plotting statements for drawing lines, polygons, points, etc Raphael Stoeckli wrote: > > Hi @ all > > I try to plot a static DC-Object (means: the graphic is calculated > uniquely > at runtime, depending of several parameters, and does not change while > displaying the window) in a window. > The problem is that this object continuously needs to be redrawn, because > it > vanishes during moving the window around, or if an other window is moving > over it. > I thought, a repaint-routine like that would solve the problem: > ------------------------------------- > use strict; > use Win32::GUI(); > our $WIN; > our %DC; > > &build_gui; > Win32::GUI::Dialog(); > > sub build_gui # Building the GUI > { > $WIN = new Win32::GUI::Window( > -left => 200, -top => 200, -width => 300, -height => 300, > -name => "WIN", > -text => "Static-DC-Test", > #-noflicker => 1, # Useless/worse result > ); > $WIN->Show(); > $DC{'color'}{'white'} = [255,255,255]; > $DC{'color'}{'red'} = [255,0,0]; > $DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width => > 3, ); > $DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'}, > -width => 1, ); > &repaint; > $DC{'timer'} = $WIN ->AddTimer("timer", 100); > } > > sub ::timer_Timer # Repaint DC with interval of 'timer' > { &repaint; } > > sub WIN_Terminate { return -1; } > > sub repaint # Create/rebuild DC-Object > { > $DC{'dc'}{'object'} = $WIN -> GetDC; > $DC{'dc'}{'object'} -> FillRect(10, 10, 280, 260,$DC{'brush'}); > $DC{'dc'}{'object'} -> SelectObject($DC{'pen'}); > $DC{'dc'}{'object'} -> BeginPath(); > $DC{'dc'}{'object'} -> MoveTo(10, 10); > $DC{'dc'}{'object'} -> LineTo(280, 260); > $DC{'dc'}{'object'} -> EndPath(); > $DC{'dc'}{'object'} -> StrokePath(); > #$DC{'dc'}{'object'} -> Save(); # ??? Save() --> Restore() ??? > } > ------------------------------------- > But the result of the code above is a flickering, annoying graphic. > So the next thought, was to generate a bitmap from the DC. There is, if > Im > not wrong, a method with DIBitmap. But, I would like to refrain from > binding > in that module, only for converting a single graphic, because its > bloating > up the program/PAR-binary. > > > Sadly, the DC-Documentation is frequent a sealed book for me. > Does anyone know an easy method (I also like to take a complex solution > :-)) > to convert a DC into a bitmap-object, without using DIBitmap? Or, even > better, a way to prevent that flickering during the repaint? > > Thanks a lot. > > Regards, > Raphael > > > ---------------------------------------------------------------------------- -- > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, > CA > -OSBC tackles the biggest issue in open source: Open Sourcing the > Enterprise > -Strategies to boost innovation and cut costs with open source > participation > -Receive a $600 discount off the registration fee with the source code: > SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > > -- View this message in context: http://www.nabble.com/flickering-static-DC-tp22404906p22411762.html Sent from the perl-win32-gui-users mailing list archive at Nabble.com. ---------------------------------------------------------------------------- -- _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users http://perl-win32-gui.sourceforge.net/ |
|
From: Jason P. <ma...@wa...> - 2009-03-11 02:30:12
|
Unfortunately, the standalone runtimes are 75% of that package, no matter which packager you use. Even though they really just zip up the files and then temporarily extract them and spit them through the runtime, you can only pack the xs so far. If someone packed perl into a .net clr it would work so much cleaner, but then the user would still need that runtime! On 3/10/09, Raphael Stoeckli <win...@ra...> wrote: > Hi Zak > > I run probably an old version of ASPerl (5.8.6.811). There is an error, when > I try to run test8.pl or test13.pl. Hook ‘Perl_newXS_flags’ was not found in > perl58.dll. I think, I remained on 5.8.6.811, because of some > PAR-compatibility-issues (most likely obsolote now). I will try it on an > other machine with 5.8.8 or 5.10 the next days. > My program works now pretty good, without much flickering, only with > win32-GUI-corefunctions. I will also try to move my window-DC into a > memory-DC the next days, as I said in my last post. I will post some > sample-code when I finished that. > To tell the truth, DIBitmap and GD frighten me a little bit. Is not that I > don't understand it – already worked with DIBitmap intensively. But my > program will be a standalone-binary for PCs without Perl. Even though > 1TB-HDDs are on the advance, I am still skeptic if I have a binary of more > than 3 or 4 MB in front of me, to run a really simple program. Maybe I am > too conservative :-) > > Anyhow, much thanks for your hint. I will also study the two posts from > mail-archive.com. > > Greetings, > Raphael > > -----Ursprüngliche Nachricht----- > Von: zak3 [mailto:zak31415@.....com] > Gesendet: Montag, 9. März 2009 12:57 > An: per...@li... > Betreff: Re: [perl-win32-gui-users] flickering static-DC > > > Hi > also look to this link about drawing and refreshing: > http://www.nabble.com/Draw-on-click-and-refresh-the-window---resolved-td1809 > 3899.html > and the two tutorials by rob may about drawing and refreshing: > http://www.mail-archive.com/per...@li.../msg05 > 194.html > http://www.mail-archive.com/per...@li.../msg05 > 195.html > > also before three days i have found an example in the win32gui demos : > demos\DIBitmap\ the first is test8.pl and test13.pl they draw a circle > without any flickering, they use GD graphics with DIBitmap, first install GD > Graphics from this site:http://www.bribes.org/perl/ppmdir.html > using the command: > ppm install http://www.bribes.org/perl/ppm/GD.ppd > and try the test8.pl and test13.pl, the GD graphics have many plotting > statements for drawing lines, polygons, points, etc > > > Raphael Stoeckli wrote: >> >> Hi @ all >> >> I try to plot a static DC-Object (means: the graphic is calculated >> uniquely >> at runtime, depending of several parameters, and does not change while >> displaying the window) in a window. >> The problem is that this object continuously needs to be redrawn, because >> it >> vanishes during moving the window around, or if an other window is moving >> over it. >> I thought, a repaint-routine like that would solve the problem: >> ------------------------------------- >> use strict; >> use Win32::GUI(); >> our $WIN; >> our %DC; >> >> &build_gui; >> Win32::GUI::Dialog(); >> >> sub build_gui # Building the GUI >> { >> $WIN = new Win32::GUI::Window( >> -left => 200, -top => 200, -width => 300, -height => 300, >> -name => "WIN", >> -text => "Static-DC-Test", >> #-noflicker => 1, # Useless/worse result >> ); >> $WIN->Show(); >> $DC{'color'}{'white'} = [255,255,255]; >> $DC{'color'}{'red'} = [255,0,0]; >> $DC{'pen'} = new Win32::GUI::Pen( -color => $DC{'color'}{'red'}, -width => >> 3, ); >> $DC{'brush'} = new Win32::GUI::Brush( -color => $DC{'color'}{'white'}, >> -width => 1, ); >> &repaint; >> $DC{'timer'} = $WIN ->AddTimer("timer", 100); >> } >> >> sub ::timer_Timer # Repaint DC with interval of 'timer' >> { &repaint; } >> >> sub WIN_Terminate { return -1; } >> >> sub repaint # Create/rebuild DC-Object >> { >> $DC{'dc'}{'object'} = $WIN -> GetDC; >> $DC{'dc'}{'object'} -> FillRect(10, 10, 280, 260,$DC{'brush'}); >> $DC{'dc'}{'object'} -> SelectObject($DC{'pen'}); >> $DC{'dc'}{'object'} -> BeginPath(); >> $DC{'dc'}{'object'} -> MoveTo(10, 10); >> $DC{'dc'}{'object'} -> LineTo(280, 260); >> $DC{'dc'}{'object'} -> EndPath(); >> $DC{'dc'}{'object'} -> StrokePath(); >> #$DC{'dc'}{'object'} -> Save(); # ??? Save() --> Restore() ??? >> } >> ------------------------------------- >> But the result of the code above is a flickering, annoying graphic. >> So the next thought, was to generate a bitmap from the DC. There is, if >> I’m >> not wrong, a method with DIBitmap. But, I would like to refrain from >> binding >> in that module, only for converting a single graphic, because it’s >> bloating >> up the program/PAR-binary. >> >> >> Sadly, the DC-Documentation is frequent a sealed book for me. >> Does anyone know an easy method (I also like to take a complex solution >> :-)) >> to convert a DC into a bitmap-object, without using DIBitmap? Or, even >> better, a way to prevent that flickering during the repaint? >> >> Thanks a lot. >> >> Regards, >> Raphael >> >> >> > ---------------------------------------------------------------------------- > -- >> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, >> CA >> -OSBC tackles the biggest issue in open source: Open Sourcing the >> Enterprise >> -Strategies to boost innovation and cut costs with open source >> participation >> -Receive a $600 discount off the registration fee with the source code: >> SFAD >> http://p.sf.net/sfu/XcvMzF8H >> _______________________________________________ >> Perl-Win32-GUI-Users mailing list >> Per...@li... >> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >> http://perl-win32-gui.sourceforge.net/ >> >> > > -- > View this message in context: > http://www.nabble.com/flickering-static-DC-tp22404906p22411762.html > Sent from the perl-win32-gui-users mailing list archive at Nabble.com. > > > ---------------------------------------------------------------------------- > -- > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > > > ------------------------------------------------------------------------------ > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > -- Sent from my mobile device Maximus* WarheadsSE MaxSource |