ShehzadMunir
asked on
How to reduce the size of the image.
The situation is some what like that I create an image, copy it to clip board and then transfer it to Picture Control from there I save it on the disk. Now if I save a picture from Oicture control it size goes to 1.3 Mb whereas if I openn the same image in the Microsoft Photo editor and save the picture the size just goes to 1.4 kb. How can I make it possible that when I save the picture fom Picture control it should be saved in kb. Though i save it using the following statement in JPEG format
SavePicture picDesktop.Image, "C:\ImageName.jpg"
SavePicture picDesktop.Image, "C:\ImageName.jpg"
The SavePicture will not work to save in JPEG format. There's a free DLL that will do the job just fine at www.vbaccelerator.com (just look in the Media section).
Use the following code:
Private Sub ScalePicture()
Dim h As Long
Dim w As Long
Dim pic As StdPicture
'Get the picture loaded in picSrc
'or load a picture using the "Open" dialog box
Set pic = picSrc.Picture
'Make sure we have a picture
If pic = 0 Then Exit Sub
'Convert the height and width to twips
h = ScaleY(pic.Height, vbHimetric, vbTwips)
w = ScaleX(pic.width, vbHimetric, vbTwips)
'Scale the destination picturebox to maintain
'the same aspect ratio as original picture
'but have max dimension of MAX_SIZE
With pctScale
'If w > h Then
' .Width = MAX_SIZE
' .Height = (h / w) * MAX_SIZE
'Else
' .Height = MAX_SIZE
' .Width = (w / h) * MAX_SIZE
'End If
'Clear previous image and picture
.Cls
.Picture = LoadPicture("")
'Scale the picture into the destination picbox
.PaintPicture pic, 0, 0, .width, .Height, 0, 0, w, h, vbSrcCopy
'Convert the drawn image to the picture
Set .Picture = .Image
'Optionally save with "Save As" dialog box:
'SavePicture .Picture, "c:\thumb.bmp"
End With
'Clear the pic object
Set pic = Nothing
End Sub
Good luck!!
Private Sub ScalePicture()
Dim h As Long
Dim w As Long
Dim pic As StdPicture
'Get the picture loaded in picSrc
'or load a picture using the "Open" dialog box
Set pic = picSrc.Picture
'Make sure we have a picture
If pic = 0 Then Exit Sub
'Convert the height and width to twips
h = ScaleY(pic.Height, vbHimetric, vbTwips)
w = ScaleX(pic.width, vbHimetric, vbTwips)
'Scale the destination picturebox to maintain
'the same aspect ratio as original picture
'but have max dimension of MAX_SIZE
With pctScale
'If w > h Then
' .Width = MAX_SIZE
' .Height = (h / w) * MAX_SIZE
'Else
' .Height = MAX_SIZE
' .Width = (w / h) * MAX_SIZE
'End If
'Clear previous image and picture
.Cls
.Picture = LoadPicture("")
'Scale the picture into the destination picbox
.PaintPicture pic, 0, 0, .width, .Height, 0, 0, w, h, vbSrcCopy
'Convert the drawn image to the picture
Set .Picture = .Image
'Optionally save with "Save As" dialog box:
'SavePicture .Picture, "c:\thumb.bmp"
End With
'Clear the pic object
Set pic = Nothing
End Sub
Good luck!!
Oh! Sorry, i don't understand the question before... You may use Intel JPEG Library for that and use the desired quality compression to reduce the image size... you can found it at: http://developer.intel.com/software/products/perflib/ijl/index.htm
You will find a VB sample to use it...
You will find a VB sample to use it...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello ShehzadMunir, Netminder is a Moderator of this site and is doing the job asked of him, one is cleaning old questions. Perhaps you had forgotten about it, and we leave reminders to bring the question back if you are still in need of help, or to finalize the question.
Another point is, we do not award Moderators points, therefore yours will be returned, and I will also change the grade to an A. As this also affects you, Experts will often times check the grading of a Memeber, and if (s)he grades poorly, many may not be interested.
Best regards,
ComTech
CS Admin @ EE
Another point is, we do not award Moderators points, therefore yours will be returned, and I will also change the grade to an A. As this also affects you, Experts will often times check the grading of a Memeber, and if (s)he grades poorly, many may not be interested.
Best regards,
ComTech
CS Admin @ EE
FidoBoy,
Unfortunately, there is no way to reject an accepted "Answer" in order to award the points properly. As such, I have created a question for you at https://www.experts-exchange.com/jsp/qShow.jsp?qid=20257171 .
Netminder
Community Support Moderator
Experts Exchange
Unfortunately, there is no way to reject an accepted "Answer" in order to award the points properly. As such, I have created a question for you at https://www.experts-exchange.com/jsp/qShow.jsp?qid=20257171 .
Netminder
Community Support Moderator
Experts Exchange