Solved

How to resize picture in file with VB6 and keep transparent colour

Posted on 2011-02-20
7
1,343 Views
Last Modified: 2012-05-11
Hi Experts!

I need a ActiveX component or code which to use with VB6 and it should works with graphic files and to have these futures:
1.      To make resize of pictures in format BMP, JPG, GIF, PNG is a plus
2.      It should be able to keep transparent color of GIF file

Till now I found PowerResize of Mark, it works fine but do not keep transparent colour.
0
Comment
Question by:dvplayltd
  • 4
  • 2
7 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34942362
UNTESTED WITH GIF

Try this simple code.

Please insert a Picture box control in your form.

This code will re size the image and create 9 copies. You may change the code to get relevant copies.

Private Sub Command1_Click()
    Dim pic1 As Picture
    
    '~~> Your Picture Path here
    Set pic1 = LoadPicture("C:\MyPic.bmp")
    Picture1.Visible = False
    '~~> Make Form Scalemode = Pixels
    Picture1.Container.ScaleMode = vbPixels
    '~~> Make PictureBox Scalemode = Pixels
    Picture1.ScaleMode = vbPixels
    Picture1.BorderStyle = 0
    Picture1.AutoRedraw = True
    
    '~~> (Create a Saves Folder in your App.Path or change to another valid folder as last parameter)
    ResizePics Me.Picture1, pic1, -20, 20, -20, 20, 20, 20, App.Path & "\saves\"
End Sub


Private Sub ResizePics(pBox As PictureBox, pPic As Picture, xFrom As Long, Xto As Long, _
                                                                         yFrom As Long, yTo As Long, _
                                                                         xStep As Long, yStep As Long, _
                                                                         pSavePath As String)
    Dim PicWidth As Long, PicHeight As Long, i As Long, j As Long

    PicWidth = pBox.ScaleX(pPic.Width, vbHimetric, vbPixels)
    PicHeight = pBox.ScaleY(pPic.Height, vbHimetric, vbPixels)
    
    For i = PicWidth + xFrom To PicWidth + Xto Step xStep
        For j = PicHeight + yFrom To PicHeight + yTo Step yStep
            pBox.Width = i
            pBox.Height = j
            pBox.Cls
            pBox.PaintPicture pPic, 0, 0, i, j
            SavePicture pBox.Image, pSavePath & "Sample (" & i & " x " & j & ").bmp"
        Next
    Next
End Sub

Open in new window


Sid
0
 

Author Comment

by:dvplayltd
ID: 34942569
I have a code which change the size of picture, BUT MY QUESTION IS TO WORKS with .gif and with transperant colour!
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 34943837
try this link:
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 500 total points
ID: 34943854
try this link:
     http://www.chestysoft.com/imagefile/instructions.pdf


11.3. Visual Basic
For best results import the csImageFile type library into VB by selecting "Project" from the menu bar,
then "References". The dialogue box will then show available type libraries. Scroll down to
"csImageFile Library", check the box and click OK. This will add the "Manage" class from
csImageFile to the Object Browser, making it available for early binding.
To create an instance of the object called "Image" use the following code:
Dim Image As Manage
Set Image = CreateObject("csImageFile.Manage")
Displaying an image from csImageFile in a VB picture box is not simple as it involves an API call to
create a bitmap. There is a description of this and some sample code on our web site at:
www.chestysoft.com/imagefile/vbimage.asp
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 34943891

Excel seems to have the capabilities you are looking for.  See this link:
       http://office.microsoft.com/en-us/excel-help/about-drawing-objects-and-pictures-HP005236498.aspx
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 34943927
see also this link:
           http://www.informatik.com/tiffdll.html
0
 

Author Closing Comment

by:dvplayltd
ID: 34995724
The library is not free.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question