-
Change Image Resolution
I am using VB6-SP6. I have a function that allows the user to load a JPG or BMP file into an Image Box control on a form. The picture is then stored in the Access DB that is the backend to my app. My issue is that if the graphic resolution is high, it obviously adds a lot to the size of the Access DB. As the graphic does not need to be displayed at a high resolution, I am trying to find a way to reduce the resolution of the graphic when it is selected to be reduced to 640x480. Does anyone have any ideas on this?
My optimal goal would be to reduce the resolution (proportionally, of course) to the closest resolution to 640x480 as some of the graphics are not on a proportional scale to 640x480 (some of the graphics might be 1536x2048 or so on).
Thanks,
The Merg
Today's problems don't worry me,
I haven't solved yesterday's yet.
-
Put a PictureBox in your form (it can be invisible), and set the AutoRedraw to True (so it keeps the image in memory)
Load your file in a StdImage, resize the PictireBox as you wish, and paint the image into it. Save the Image.
Marco
Code:
Dim std As StdPicture
Set std = LoadPicture( ... the name of the image file ... )
With Picture1
.AutoRedraw = True
.Width = 640 * Screen.TwipsPerPixelX '' 640 pixels
.Height = .Width * std.Height / std.Width '' keep the rigth aspect ratio
.PaintPicture std, 0, 0, .Width, .Height
SavePicture .Image, "c:\w.jpg" '' save the Image, not the Picture!
End With
"There are two ways to write error-free programs. Only the third one works."
Unknown
-
That code is very close to what I'm looking for. However, I don't necessarily need to have the graphic resaved in the smaller resolution. I just want the graphic to be resized when it is loaded into the app so that when it is stored in the Access DB it will take up less space.
Can I possibly use the code you specified with an Image Box and take advantage of the Image Box's stretch property?
Thanks,
The Merg
Today's problems don't worry me,
I haven't solved yesterday's yet.
-
Well, I gave your code a try. At the end, instead of doing the SavePicture commmand, I just assigned the .Image property to the ImageBox that I use to display the picture. The image is then saved into the database when the record is updated.
Works great! Thanks!
- The Merg
Today's problems don't worry me,
I haven't solved yesterday's yet.
-
 Originally Posted by The Merg
Well, I gave your code a try. At the end, instead of doing the SavePicture commmand, I just assigned the .Image property to the ImageBox that I use to display the picture. The image is then saved into the database when the record is updated.
Works great! Thanks!
- The Merg
you are welcome.
As you found out, in my code I was saving the resolved picture in a file as an example (and to test that it was working) on how to use the Image property to get the image back
Marco
"There are two ways to write error-free programs. Only the third one works."
Unknown
-
in order to get the closest resolution you want. you can either resize images c# or scale to the size you think it is proper and the save the image.
-
 Originally Posted by drimage
in order to get the closest resolution you want. you can either resize images c# or scale to the size you think it is proper and the save the image.
Well, as you can see I've already resolved the issue, plus that was from over 7 years ago...
- Merg
Today's problems don't worry me,
I haven't solved yesterday's yet.
Similar Threads
-
By Arkie_student in forum Java
Replies: 7
Last Post: 05-15-2005, 01:03 PM
-
By vbdude in forum VB Classic
Replies: 4
Last Post: 02-12-2005, 07:40 AM
-
By Bill in forum Open Source
Replies: 4
Last Post: 01-14-2002, 04:27 AM
-
Replies: 3
Last Post: 08-30-2001, 11:45 AM
-
By Vincent in forum ASP.NET
Replies: 0
Last Post: 12-04-2000, 08:46 AM
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|