?
Solved

How use MsPaint.exe in VB5 to open PNG picture and save it in BMP ?

Posted on 2008-06-25
21
Medium Priority
?
3,191 Views
Last Modified: 2011-10-19
Hi,
I have a VB5 project that I use for display some  JPG and GIF images

FotoBrowser is an Image object on my form

I include  is a part of my VB code:
  ...i can display my PICTURES.
The problem is that PNG pictures are not supported.

So: MsPaint.exe is able to open PNG files and save it AS BMP files.

The question is: How can I do it in VB? VB can use ms  paint.exe as application, pass it a png file and have as result a bmp file?
Dim img As Picture
  fotoBrowser.Picture = Nothing
 
  Private Sub imageLoadAdjCenter(img As Picture)
   ...omissis load jpg or gif file in img
  End sub
  
  fotoBrowser.Picture = img

Open in new window

0
Comment
Question by:antares2001
[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
  • 11
  • 7
21 Comments
 
LVL 22

Expert Comment

by:danaseaman
ID: 21867031
While MsPaint does support PNG it does not support 32-bit so you lose the alpha transparency channel. When you save as BMP you only get 24-bit image. That is the reason for using aicAlphaImage control which fully supports the nice looking Xp/Vista 32-bit PNG images.

You could use GDI+ to load a PNG and then convert to StdPicture but this won't work on Win98 without installing GDI+ on that Platform. aicAlphaImage control works on Win98 without the need to install GDI+.
0
 
LVL 1

Author Comment

by:antares2001
ID: 21872201
Ok,
but for my application, png converted in bmp is sufficient, (low level user public image viewer).
In any case I'm glad to undestood MsPaint interfacing in visual basic..... if is possible
thank
0
 
LVL 13

Expert Comment

by:game-master
ID: 21880472


good morning....

u can open image file using paint in vb

check this one...


Private Sub Command3_Click()
        Dim myPath As String
        myPath = "C:\xxx.bmp"
        Debug.Print myPath
        Shell "C:\WINDOWS\system32\mspaint.exe" & " " & myPath, vbMaximizedFocus
       
       
End Sub

this snippet will show the image in mspaint...

i hope this give u and idea...

game-master
0
Industry Leaders: 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 1

Author Comment

by:antares2001
ID: 21881228
Hi,
this is the first part of my job....
then I have to save the file opened.....
In other word, visual basic have to do:
- run MsPaint
- open "picture.png" with MsPaint

case 1
- "save as" "picture.bmp" using MsPaint

or if case1 is impossible

case 1
- select all "picture" from MsPaint
- paste "picture" in vb image control  (image1.picture = "mspaint-picture)

is possible that?
regards

 
0
 
LVL 13

Expert Comment

by:game-master
ID: 21881259


why to do u need to saveas the image on the paint?

if your goal is to saveas the image to the specific location,
well it think u can use the filesystemobject to copy the specific image
to your desired location..
and then showed it using the mspaint...


game-master
0
 
LVL 1

Author Comment

by:antares2001
ID: 21881295
Sorry,
I try to be more clear:
I have a VB application that was written time ago from a consultant. It shows BMP,  JPG and GIF pictures in special mode... but PNG are not supported, because IMAGE control of VB5/6 don't support PNG.

MsPaint is able to open PNG and SAVE AS  BMP 24 bit.

My goal is to made a simple modify to my VB application with a new procedure that "preload PNG by way of MsPaint (or other way), save it AS BMP and then continue my application with normal run.
 
I'm  novice programmer, and this is a simple way... but I can't do it.
More ideas?
0
 
LVL 13

Accepted Solution

by:
game-master earned 480 total points
ID: 21896128
Private Sub Command3_Click()
        Dim myPath As String
        myPath = "C:\xxx.bmp"
        Debug.Print myPath
        Shell "C:\WINDOWS\system32\mspaint.exe" & " " & myPath, vbMaximizedFocus
       
       
End Sub
0
 
LVL 1

Author Comment

by:antares2001
ID: 21897467
game-master,
I 'm running on your path and my job is in progress, but not ended....
please help me to save MsPaint opened file ( complete ?????? code)
Thank you


' MAIN
' Open a PNG image using MsPaint (ok)
'_______ this command is same to:  Run MsPaint -> Open FIle C:\italy1.png)
          call OpenPngInMsPaint()
 
' Save MsPaint opened picture AS BMP format 
'______ (this command is same to:  From running MsPaint -> Save As C:\italy1.bmp)
         call SaveMsPaintOpenedFileAsBmp()
' END OF MAIN
 
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Private Sub OpenPngInMsPaint()
        Dim myPath As String
        myPath = "C:\italy1.png"
        Debug.Print myPath
        Shell "C:\WINDOWS\system32\mspaint.exe" & " " & myPath, vbMaximizedFocus
End Sub
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Private Sub SaveMsPaintOpenedFileAsBmp()
                     ??????????
                     ??????????
                     ??????????
                     ??????????
End Sub
' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Open in new window

0
 
LVL 1

Author Comment

by:antares2001
ID: 21897477
A file png format
italy1.PNG
0
 
LVL 1

Author Comment

by:antares2001
ID: 21897506
The file PNG opened from MsPaint and saved as BMP (from windows  - I have to do it from VB)
italy1.bmp
0
 
LVL 13

Expert Comment

by:game-master
ID: 21897537


good afternoon...

i try this code and works fine on me...


Private Sub Command3_Click()
        Dim myPath As String
        myPath = "C:\italy1.PNG"
        Debug.Print myPath
        Shell "C:\WINDOWS\system32\mspaint.exe" & " " & myPath, vbMaximizedFocus
        Debug.Print "C:\WINDOWS\system32\mspaint.exe" & " " & myPath & "xxx.bmp"
       

        'i use this code to copy the png file to my "Drive C" and saved the image as "myTest.bmp"

        FileCopy myPath, "c:\myTest.bmp"

       'i just used this message box to know if the program runs through my code.
       
        MsgBox "OK"  
       
End Sub


i hope will give u some idea..

game-master
0
 
LVL 1

Author Comment

by:antares2001
ID: 21897601
Sorry!
Your code create a file xxx.bmp ... but this is a png file.
italy1.png size 21kb - header 0PNG.......


xxx.bmp size 21kb - header 0PNG.......

If I do it fro ms paint with command SAVE AS BMP I have this:
italy1.bmp size 262kb - header BMî.........
0
 
LVL 13

Expert Comment

by:game-master
ID: 21897667


yes...

i been working for your question...
i am also new to that instance...

lets both work it out...


game-master
0
 
LVL 1

Author Comment

by:antares2001
ID: 21915577
Hi all
more info?
0
 
LVL 13

Expert Comment

by:game-master
ID: 21922527


good morning...

i'm sorry...
i was out on the office for how many days..


i heard u can use the api function "shellexecute"

here is the declaration..

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


'this is a sample way to use it..

sub <your procedure name for example>
ShellExecute Me.hwnd, vbNullString, "mailto:KPDTeam@Allapi.net", vbNullString, "C:\", SW_SHOWNORMAL
end sud
0
 
LVL 1

Author Comment

by:antares2001
ID: 21923070
Hi,
I'm in confusion...      ;-()

Are you rure that this sample "make" SAVE AS BMP from MsPaint?
0
 
LVL 13

Expert Comment

by:game-master
ID: 21930455


what i am imposing on my posted comment is that,
that is how to use the shellexecute...but that is not the
code to save a bitmap...
0
 
LVL 1

Assisted Solution

by:antares2001
antares2001 earned 480 total points
ID: 21943027
... in other wods is not possible do it?
0
 
LVL 1

Author Comment

by:antares2001
ID: 21963228
Sorry, nobody answer my question:
How use MsPaint.exe in VB5 to open PNG picture and save it in BMP ?
0

Featured Post

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!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…
Suggested Courses

752 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