HighTechTalks DotNet Forums  

position of a Bitmap

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


Discuss position of a Bitmap in the Dotnet Framework (Drawing) forum.



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

Default position of a Bitmap - 01-02-2007 , 03:44 PM






Is there a reasonably easy way to find the position of a Bitmap in a
PictureBox? With the PictureBox's AutoSize property set to Zoom, it
doesn't seem like there would be any way to figure it out, at least
without knowing the zoom factor, and even then, there doesn't seem to be
anything in either the PictureBox or Bitmap class to give a hint.

Does anybody have any ideas?

Thanks,
Lee Crabtree

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

Default Re: position of a Bitmap - 01-07-2007 , 01:27 PM






My advice here would be to scrap using PB and write your own control.
A reasonable PB control can be created in about 15 minutes derived from a
panel or a simple control.
The image position can be obtained by simple backtracking (see the GDI+
FAQ).
For the basic picturebox functionality see the zoompicbox.

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

Ramuseco Limited .NET consulting
http://www.ramuseco.com

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.





"Lee Crabtree" <lcrabtree (AT) goisi (DOT) com> wrote

Quote:
Is there a reasonably easy way to find the position of a Bitmap in a
PictureBox? With the PictureBox's AutoSize property set to Zoom, it
doesn't seem like there would be any way to figure it out, at least
without knowing the zoom factor, and even then, there doesn't seem to be
anything in either the PictureBox or Bitmap class to give a hint.

Does anybody have any ideas?

Thanks,
Lee Crabtree



Reply With Quote
  #3  
Old   
Lee Crabtree
 
Posts: n/a

Default Re: position of a Bitmap - 01-08-2007 , 10:40 AM



If it was anybody else suggesting it, I'd probably tell them to drop
dead. But, as I've made use of your suggestions and information more
than once, I'll give it a whirl.

It's just frustrating that something that seems so important would be
hidden so insidiously.

Thanks,
Lee Crabtree

Bob Powell [MVP] wrote:
Quote:
My advice here would be to scrap using PB and write your own control.
A reasonable PB control can be created in about 15 minutes derived from a
panel or a simple control.
The image position can be obtained by simple backtracking (see the GDI+
FAQ).
For the basic picturebox functionality see the zoompicbox.


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

Default Re: position of a Bitmap - 01-08-2007 , 04:41 PM



Well, the problem is that if you look at the PictureBox with Reflector
you can see that they have a method called ImageRectangleFromSizeMode.

In the paint, they just draw the image into this rectangle.

The problem here is that A. they don't use transforms at-all, which
would be the sensible way to do it and B. the rectangle isn't available,
unless of course you fiddle in the internals with reflection.

This means that picturebox retains its reputation as an utter POS and
for your purposes it's next to useless.

If I had the time I'd write the darned thing for you but i'm a wee bit
up to my ears in work at the moment.

Zoompicbox is a good start, then read that backtracking article and
maybe the one on understanding autoscroll.

You'll get there.

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

Ramuseco Limited .NET consulting
http://www.ramuseco.com

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.





Lee Crabtree wrote:
Quote:
If it was anybody else suggesting it, I'd probably tell them to drop
dead. But, as I've made use of your suggestions and information more
than once, I'll give it a whirl.

It's just frustrating that something that seems so important would be
hidden so insidiously.

Thanks,
Lee Crabtree

Bob Powell [MVP] wrote:
My advice here would be to scrap using PB and write your own control.
A reasonable PB control can be created in about 15 minutes derived
from a panel or a simple control.
The image position can be obtained by simple backtracking (see the
GDI+ FAQ).
For the basic picturebox functionality see the zoompicbox.


Reply With Quote
  #5  
Old   
Lee Crabtree
 
Posts: n/a

Default Re: position of a Bitmap - 01-08-2007 , 04:48 PM



Merely knowing I'm not crazy and missing something elementary makes me
feel much better.

Lee Crabtree

Bob Powell [MVP] wrote:
Quote:
Well, the problem is that if you look at the PictureBox with Reflector
you can see that they have a method called ImageRectangleFromSizeMode.

In the paint, they just draw the image into this rectangle.

The problem here is that A. they don't use transforms at-all, which
would be the sensible way to do it and B. the rectangle isn't available,
unless of course you fiddle in the internals with reflection.

This means that picturebox retains its reputation as an utter POS and
for your purposes it's next to useless.

If I had the time I'd write the darned thing for you but i'm a wee bit
up to my ears in work at the moment.

Zoompicbox is a good start, then read that backtracking article and
maybe the one on understanding autoscroll.

You'll get there.


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.