[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
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,255 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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 have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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

656 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