|
-
Apr 16th, 2001, 01:34 PM
#1
Thread Starter
Member
Hello All,
As the subject line say's, I would like to center graphics (pictures) in a picturebox control.
A) The pictureboxes border is fixed, creating a nice viewable frame.
B) I would like to center to fit large, small, and irregularly shaped pictures. Maintaining the aspect ratio of those pictures. An example of an irregularly shaped picture would be one that is taller than it is wide etc.....
I am able to display and center these types of pictures on a full sized screen (form), but unable to do so in a picturebox. I have tried the following:
Putting an imagebox on the picturebox and find that any image that is put in the image box is displayed on the form behind the picturebox.
Putting a second picturebox on the first one, the picture doesn't display within the first one. It kind of hovers above it, though it may be centering on the form, I'm not sure if this is the case though.
An imagebox set to stretch, distorts the irregularly shaped pictures. I can change the shape of the fixed imagebox so pictures are less or not distorted at all. This makes the GUI look terrible.
Does anyone have any ideas about what would work and allow me to do this? API calls might do it however I'm not sure how to proceed in doing that. Hmm... I've just recalled seeing something about placing pictures in rich textboxes some where, I'll look for that after I've posted this. If anyone has any ideas, suggestions, etc... I would appreciate it.
Thanks in advance.
Jerome W. Norgren
"Know how to ask. There is nothing more difficult for some people, nor for others, easier."
- Baltasar Gracian
-
Apr 17th, 2001, 02:56 AM
#2
Fanatic Member
How about simply putting another picturebox inside the 'nice viewport', set it's AutoSize property to True and BorderStyle to None, and run code something like this:
(picViewport is the large picturebox with the border you described and picImage is the actual image)
Code:
picImage.Picture = LoadPicture("C:\Blabla.bmp")
With picImage
.Top = (picViewport.ScaleWidth - picImage.Width) / 2
.Left = (picViewport.ScaleHeight - picImage.Height) / 2
End With
Teaudirenopossum.Musasapientumfixaestinaure.
(I can't hear you. There's a banana in my ear)
-
Apr 17th, 2001, 05:11 AM
#3
transcendental analytic
case analysis
compare > the ratios between width and height for both the picture and the frame and base the resizing ratio on framewidth/picturewidth in first case and frameheight/pictureheight in second case
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|