Solved

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

Posted on 2011-02-20
7
1,397 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 7 hours left to enroll

623 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