Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
I have created a program which is more on loading an image. I have already finish my program but I have still a problem in running my program. My program is too slow because of large images.
I try this code to make the images lighter but it doesn't work.
VB
Public Sub LoadImage(ByVal imgName As String)
    With Entry1
        .imgView.ScrollBars = SB_Both
        .imgView.ViewUpdate = True
        .imgView.ToolSet TOOL_Hand, IXMOUSEBUTTON_Left, 0
        .imgView.PageNbr = imgPage
        .imgView.fileName = imgPath & imgName
        .imgView.IResX = 300
        .imgView.IResY = 300
        '.imgView.AutoSize = ISIZE_ResizeImage
        .imgView.SaveFile
        .imgView.ZoomToFit ZOOMFIT_BEST
    End With
End Sub



Is there any way to make the images lighter? or to resize an image?
Any help will be accepted.
Posted
Updated 24-Jun-18 20:13pm

If you use Image control[^], you can use simply trick from: http://visualbasic.freetutes.com/learn-vb6/picturebox-image-controls.html[^]
VB
' Load a bitmap.
Image1.Stretch = False
Image1.Picture = LoadPicture("c:\windows\setup.bmp")
' Reduce it by a factor of two.
Image1.Stretch = True
Image1.Move 0, 0, Image1.Width / 2, Image1.Width / 2


Another way to increase performance, is to use AutoRedraw property.
VB
Image1.AutoRedraw = True 'False


For PictureBox control, refer this: http://msdn.microsoft.com/en-us/library/zzt5x46b%28v=vs.80%29.aspx[^]
VB
Picture1.AutoSize = True 'False


Have a look here:
http://stackoverflow.com/questions/12516376/resizing-a-picture-to-a-fixed-size-in-vb6[^]
http://www.chestysoft.com/ximage/vb/image-resize-vb.asp[^]
 
Share this answer
 
A Best solution for you

VB
Sub PHOTO_RESIZING()
Dim obj As Object
Dim rngInsert As Range
Dim dblZoom As Double
If TypeName(Selection) = "Range" Then Exit Sub
Set obj = Selection
Set rngInsert = obj.TopLeftCell ' Selection
Set rngInsert = rngInsert.MergeArea
Application.ScreenUpdating = False
    rngInsert.Select
        dblZoom = ActiveWindow.Zoom
        ActiveWindow.Zoom = 100 'View Resizing
    With obj
        .ShapeRange.LockAspectRatio = msoFalse
        .Top = rngInsert.Top
        .Left = rngInsert.Left
        .Height = rngInsert.Height
        .Width = rngInsert.Width
    End With
ActiveWindow.Zoom = dblZoom
Application.ScreenUpdating = True
End Sub
 
Share this answer
 
v2
Comments
CHill60 25-Jun-18 7:54am    
Stick to answering posts where the OP still needs help, not 5 year old questions that already have a solution. This "solution" will not even compile in VB6.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900