Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-20
7
Medium Priority
?
1,418 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 1500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

715 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