Re: Appending one image to other



Never mind, I found the reason for the slowness.

I was using my own double-buffering, but so was the control too!! In effect,
I was quadruple buffering (Double-buffering twice!).

"Garry Freemyer" <garryfre@xxxxxxxxxxxxxxxxxxx> wrote in message
news:e3dpHgwZFHA.4068@xxxxxxxxxxxxxxxxxxxxxxx
> Hiya Sir, I have written a screensaver program and I noticed your FAQ
> where it says to do all painting in the paint routine and to Never ever
> "Steal" a graphics object to do painting outside of events. I just have a
> couple of questions for ye ...
>
> 1. The program as I have it written now, seems to work fine, however I
> decided to give your adivice in the GDI+ Faq a try, and have the
> SaverLoop, just draw to an offscreen bitmap, but then utilize the Paint
> event of the form to do the actual drawing on the form. This seems to work
> ok, albiet it is drastically slower! ....
>
> When saver loop is done with drawing to the bitmap, it calls invalidate
> and this triggers the Paint routine then calls Application.DoEvents();
> then repeats unless the user touched a key or moved or clicked the mouse.
>
> Here is the Paint event ...
>
> private void ScreenSaverForm_Paint(object sender,
> System.Windows.Forms.PaintEventArgs e)
>
> {
>
> if (this.SaverStarted == true) // Since saverLoop is a loop, don't call it
> twice.
>
> {
>
> e.Graphics.DrawImage(bm,0,0,bm.Width,bm.Height);
>
> }
>
> }
>
>
> 2. I wonder if this really applies when it comes to screensavers. I like
> the simplicity of this, it eliminates my having to create a timer to call
> SaverLoop which turns off the timer immediately, and it looks somewhat
> less complicated but still its dramatically slower. Does this rule really
> apply when you are using a screensaver, where you don't care if an object
> covers over the form because then you want to quit anyway.
>
> 3. My final concern is that most screensavers, including mine, write to
> the mini-preview box on the Display Properties dialog box. This is a clear
> example of "Stealing" a graphic's object in C# as far as how I do it in
> the program. I am unable to create a control via the handle, all I get
> back is a null control. The only thing I can get from this handle is a
> Graphics object, that appears to expose NO events. Obviously, something is
> either missing as far as knowledge, or this is an exception.
>
> Thoughts please?
>
> "Bob Powell [MVP]" <bob@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:OYOfVHIYFHA.712@xxxxxxxxxxxxxxxxxxxxxxx
>> Throw that lousy PictureBox out and write your own control to display the
>> image in its correct aspect ratio.
>>
>> See the GDI+ FAQ for code that you can adapt.
>>
>> --
>> Bob Powell [MVP]
>> Visual C#, System.Drawing
>>
>> Find great Windows Forms articles in Windows Forms Tips and Tricks
>> http://www.bobpowell.net/tipstricks.htm
>>
>> Answer those GDI+ questions with the GDI+ FAQ
>> http://www.bobpowell.net/faqmain.htm
>>
>> All new articles provide code in C# and VB.NET.
>> Subscribe to the RSS feeds provided and never miss a new article.
>>
>>
>>
>>
>>
>> "Saurabh" <saurabh@xxxxxxxxxxxx> wrote in message
>> news:O1o6OYHYFHA.1796@xxxxxxxxxxxxxxxxxxxxxxx
>>> Hello All,
>>>
>>> I am new to the image processing things, hence this question might be a
>>> bit silly but I could not find any obvious solution....
>>>
>>> I have an image object which is to be shown in a picturebox. The
>>> picturebox can actually change the size depending on the anchor /
>>> docking of the form. I do not want my image to lose its aspect ratio but
>>> still want to show it within the bounds of the picturebox. I was
>>> thinking of appending whitespaces (or transparent spaces) within the
>>> image itself so that my actual picture will maintain the aspect ratio
>>> but the image object will be of the same size as that of the picturebox.
>>> (Its a bit like the way 16:9 movies appear on a 4:3 TV screen with a
>>> black band appearing at top and bottom of the screen) Does anybody know
>>> how I can append such thing in the image object. Depending on the W : H
>>> ratio of the picturebox and the picture, sometimes I want the whitespace
>>> bands at top and bottom and sometimes at left and right.
>>>
>>> TIA,
>>>
>>> --Saurabh
>>>
>>
>>
>
>


.



Relevant Pages

  • Re: Help for hDC and textcontrol.coms ActiveX Control
    ... Microsoft Picture Clip Control v6 and the new error in both ... You're picturebox control would ... >> hDC Property to Text Control's PrintDevice Property. ... >> a device context for the Printer object and for each form and PictureBox ...
    (microsoft.public.fox.programmer.exchange)
  • Re: sizing handles control
    ... Control or ScrollableControl base class and build in the desired behaviours. ... you'd like to display a bitmap on a PictureBox ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Help for hDC and textcontrol.coms ActiveX Control
    ... Windows handle or anything like that. ... You're picturebox control would need ... > hDC Property to Text Control's PrintDevice Property. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Appending one image to other
    ... decided to give your adivice in the GDI+ Faq a try, and have the SaverLoop, ... this triggers the Paint routine then calls Application.DoEvents; ... when you are using a screensaver, where you don't care if an object covers ... >> I have an image object which is to be shown in a picturebox. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: PictureBoxes and Charting
    ... It appears that the best way to add indicators to the bottom of my price ... charts is to actually add another PictureBox below the chart PictureBox ... I've always just dragged the control onto the ... array at run time using the Load and Unload ...
    (microsoft.public.vb.general.discussion)