HighTechTalks DotNet Forums  

Magnify Area w/ Transparent Windows To Form

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Magnify Area w/ Transparent Windows To Form in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Magnify Area w/ Transparent Windows To Form - 09-06-2004 , 11:21 AM






Hi, I'm trying to create a simple magnifier program, where it would
magnify an small area under the mouse coordinates, catch is, it should
also capture and magnify Transparent Forms, and paints everything to
the form.

I've manage to solve this problem using the follwing method.

1. Create new Bitmap variable and save it inside the Graphics variable
Dim b As New Bitmap(CInt(blitAreaX), CInt(blitAreaY))
Dim g As Graphics = Graphics.FromImage(b)

2. Use BitBlt Api to capture entire desktop and using "SRCCOPY Or
CAPTUREBLT" at the "dwRop" parameter.
==================================================
Public Const CAPTUREBLT As Integer = &H40000000
Public Const SRCCOPY As Integer = &HCC0020
==================================================

3. Use e.Graphics.DrawImage to draw the specified "Rectangle
Coordinate & Size" of both source & destination to the form.

-----------------------
My problems is that I find this method slow because the BitBlt Api
captures the "entire" desktop, which makes the process slow. It would
be faster if I can only capture the desired area.

I tried using StretchBlt, which is the most logical thing to do,
however using StretchBlt to paint directly to the form "Does Not"
paint transparent forms. I have tried many approches to this but to no
avail.

Approaches like, a) Use StretchBlt to draw directly to form and b) Use
StretchBlt and save result at a BMP Variable which e.Graphics would
draw.

Both of methods fail to paint transparent forms.

Any solution, suggestion or insights on how to create a fast, (if
possible flickerless) magnifier program that could also
capture/magnify transparent forms will be very much appreciated.

Thank you,
Henry Wu


Since its graphics/drawing related, I belive this is the more proper
group for my question than 1st one I've tried.

For the complete thread and source code of my work, kindly visit the
ff link:

http://groups.google.com.ph/groups?h...languages.vb.*

Reply With Quote
  #2  
Old   
Bob Powell [MVP]
 
Posts: n/a

Default Re: Magnify Area w/ Transparent Windows To Form - 09-08-2004 , 06:48 AM






I don't know why you say that the BitBlt API captures the whole screen. The
BitBlt API can capture whatever portion you tell it to.

The destination rectangle size will determine the amount of image copied.
The destination location should be 0,0 and the source X and Y should point
to the upper-left corner of the area you want to grab.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml






"Henry Wu" <henrycortezwu (AT) hotmail (DOT) com> wrote

Quote:
Hi, I'm trying to create a simple magnifier program, where it would
magnify an small area under the mouse coordinates, catch is, it should
also capture and magnify Transparent Forms, and paints everything to
the form.

I've manage to solve this problem using the follwing method.

1. Create new Bitmap variable and save it inside the Graphics variable
Dim b As New Bitmap(CInt(blitAreaX), CInt(blitAreaY))
Dim g As Graphics = Graphics.FromImage(b)

2. Use BitBlt Api to capture entire desktop and using "SRCCOPY Or
CAPTUREBLT" at the "dwRop" parameter.
==================================================
Public Const CAPTUREBLT As Integer = &H40000000
Public Const SRCCOPY As Integer = &HCC0020
==================================================

3. Use e.Graphics.DrawImage to draw the specified "Rectangle
Coordinate & Size" of both source & destination to the form.

-----------------------
My problems is that I find this method slow because the BitBlt Api
captures the "entire" desktop, which makes the process slow. It would
be faster if I can only capture the desired area.

I tried using StretchBlt, which is the most logical thing to do,
however using StretchBlt to paint directly to the form "Does Not"
paint transparent forms. I have tried many approches to this but to no
avail.

Approaches like, a) Use StretchBlt to draw directly to form and b) Use
StretchBlt and save result at a BMP Variable which e.Graphics would
draw.

Both of methods fail to paint transparent forms.

Any solution, suggestion or insights on how to create a fast, (if
possible flickerless) magnifier program that could also
capture/magnify transparent forms will be very much appreciated.

Thank you,
Henry Wu


Since its graphics/drawing related, I belive this is the more proper
group for my question than 1st one I've tried.

For the complete thread and source code of my work, kindly visit the
ff link:


http://groups.google.com.ph/groups?h...en%26lr%3D%26i
e%3DUTF-8%26q%3Dhenrycortezwu%40hotmail.com%26meta%3Dgroup %253Dmicrosoft.pub
lic.dotnet.languages.vb.*




Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default Re: Magnify Area w/ Transparent Windows To Form - 09-08-2004 , 02:38 PM



Oh I see, I always thought that since BitBlt didn't have the "source
width & height" like StretchBlt has, it would capture the entire
screen starting from the Source's X & Y coordinates, and then the
destination rectangle would just crop out what is just needed. So I'm
thinking that since StretchBlt has "source width & height", it would
just capture that rectangle only, & not like BitBlt,...(from source's
X,Y till the end),... that is why I'm thinking StretchBlt is much
faster,... well,...I've manage to use BitBlt and make the magnifier
program work to paint transparent windows, but its still not at par
with Microsoft's Magnifier which doesn't flicker at all ,...well
maybe in the future there will be some .NET examples of a magnifier
program that can paint transparent forms that has great speed and
flickerless

Thanks again for your thoughts,..
Henry
Quote:
I don't know why you say that the BitBlt API captures the whole screen. The
BitBlt API can capture whatever portion you tell it to.

The destination rectangle size will determine the amount of image copied.
The destination location should be 0,0 and the source X and Y should point
to the upper-left corner of the area you want to grab.

--
Bob Powell [MVP]
Visual C#, System.Drawing


Reply With Quote
  #4  
Old   
AT
 
Posts: n/a

Default Re: Magnify Area w/ Transparent Windows To Form - 09-25-2004 , 07:56 AM



Hi Bob Powell,
I finished the sample magnifier project that could magnify
transparent windows too. However, flickering is still a problem, If
you know any way on how to remove the flickering, I would really be
very gratefull for it!

Thanks,
Henry


Sample Magnifier Project:
http://wuhenry.beigetower.org/MagnifierXP.zip


After some research I found out that StretchBlt doesnt support
CaptureBLT.
http://groups.google.com.ph/groups?h...ered%2Bwindows

Reply With Quote
  #5  
Old   
james
 
Posts: n/a

Default Re: Magnify Area w/ Transparent Windows To Form - 09-26-2004 , 12:15 AM



Henry, I just downloaded your MagnifierXP sample project and it is really
good. If you solve the flickering problem it will be even better.
james

"Henry Wu" <henrycortezwu (AT) hotmail (DOT) com> wrote

Quote:
Hi Bob Powell,
I finished the sample magnifier project that could magnify
transparent windows too. However, flickering is still a problem, If
you know any way on how to remove the flickering, I would really be
very gratefull for it!

Thanks,
Henry


Sample Magnifier Project:
http://wuhenry.beigetower.org/MagnifierXP.zip


After some research I found out that StretchBlt doesnt support
CaptureBLT.
http://groups.google.com.ph/groups?h...ered%2Bwindows



Reply With Quote
  #6  
Old   
AT
 
Posts: n/a

Default Re: Magnify Area w/ Transparent Windows To Form - 09-29-2004 , 01:47 AM



Hi James,

Thanks in part to Dr. Screwup I finally got the Magnifier working the
way I want it.

http://wuhenry.beigetower.org/MagnifierXP-Final.zip

A Seperate repaint function was the trick to stop the flickering. Dont
call any invalidate, it will surely cause flickering.

Thanks,
Henry


Reply With Quote
  #7  
Old   
james
 
Posts: n/a

Default Re: Magnify Area w/ Transparent Windows To Form - 09-29-2004 , 04:27 PM



Thanks for sharing your code Henry, it works really well now. You have put a
lot of work into this program. (oh, and your code is well commented too)
james

<henrycortezwu (AT) hotmail (DOT) com> wrote

Quote:
Hi James,

Thanks in part to Dr. Screwup I finally got the Magnifier working the
way I want it.

http://wuhenry.beigetower.org/MagnifierXP-Final.zip

A Seperate repaint function was the trick to stop the flickering. Dont
call any invalidate, it will surely cause flickering.

Thanks,
Henry




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.