Results 1 to 12 of 12
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Saving a selected graphic as BitMap /BMP

    How can I save a selected graphic, preferably as a Windows Bitmap?

    Either it's darn near impossible, or my mind is going through one of its lengthier periodic brownouts.

    I have a set of GIF and JPeg etc files. I'd like to process them all, programmatically, and somehow convert them to BitMap form. Setting their image attributes would be nice, but not essential.

    In Word97/VBA as an example, I can write code that will Insert, Picture, From file and then Select the graphic.

    I can't see a way to save the graphic in BMP format.

    I've looked within PPT in VBA, but have very little experience there.

    I've even fired up Microsoft Photo Editor and Corel Photo House, but there's no macro/program capability there, as far as I can see.

    I don't care if the solution involves a DOS BATch file.

    I should add that I'm reasonably comfortable with working with Clipboard objects ....

    Ideally I'd like to point some procedure (VBA/DOS etc) at a directory and have it process each file in that directory. Each file would pop up on the screen in front of me (as in Word, Insert, Picture, FromFile) and I would choose to save it or ignore it. Ignore is to go on to the next file, Save is to somehow save the image as a Windows BitMap.



    I'm wondering now whether there might not be a solution if I saved it in RTF format, but that seems to me to be clutching at straws.

  2. #2
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Saving a selected graphic as BitMap /BMP

    Chris

    OK since no one has answered you yet, I will take a stab at it.

    <<<In Word97/VBA as an example, I can write code that will Insert, Picture, From file and then Select the graphic. I can't see a way to save the graphic in BMP format. >>>

    I guess this is due to the fact that the picture inserted is now in MS-Word, its an object of the document I think, not a stand alone file.

    <<< I've even fired up Microsoft Photo Editor and Corel Photo House, but there's no macro/program capability there, as far as I can see. >>>

    True and this is where you need to look, since Photo Editor can save graphical files vs Word saving documents, and Excel saving spreadsheets. But again you hit the wall where once you are in the 'shelled-to' aplication, VBA or any other automation macro can't control.

    So how about a 3rd party automation control macro thingy. Check http://"]http://www.dynawares.com/macro/>http:// http://www.dynawares.com/macro/[/url] for MacroAnyWhere. So you can launch Photo Editor via VBA and then control Photo Editor via MacroAnyWhere. Possibly it would work and it maybe too much work that you may get frustrated <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23> enough to save each image separatly, in which case you are done <img src=/S/grin.gif border=0 alt=grin width=15 height=15> and don't need a macro any more.

    Hope this helps... I don't know I never tried such approch, but maybe you will tell us.

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Saving a selected graphic as BitMap /BMP

    Why save them as bmp files ?. The quality is unlikely to improve and all you achieve is to increase the file size !.

    Andrew C

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving a selected graphic as BitMap /BMP

    > for MacroAnyWhere.

    Thanks for this. I am d/l as we squeak and will report back.

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving a selected graphic as BitMap /BMP

    > Why save them as bmp files ?.

    Wallpaper.

  6. #6
    New Lounger
    Join Date
    Sep 2005
    Location
    United Kingdom
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving a selected graphic as BitMap /BMP

    I looked into this once. I think your best chance is to use a 3rd-party graphics COM DLL, I know Lead Tools is popular (www.leadtools.com), there are probably lots of others, maybe even some free ones!

    Peter

  7. #7
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Saving a selected graphic as BitMap /BMP

    You can do this using an Image control and the LoadPicture and SavePicture statements.

    I put together this quick and dirty.

    Add a Userform with an Image control and a CommandButton.

    Then:

    Private Sub CommandButton1_Click()
    Dim myfile As String
    Dim mybmpfile As String
    Dim i As Integer

    Const pic_dir As String = "Cocuments and SettingsAdministratorMy DocumentsMy PicturesTest"
    Const bmp_dir As String = "Cocuments and SettingsAdministratorMy DocumentsMy PicturesBMPS"

    myfile = Dir(pic_dir & "*.*")

    While myfile <> ""
    i = InStr(1, myfile, ".")
    mybmpfile = Left(myfile, i - 1)
    myfile = pic_dir & myfile
    Image1.Picture = LoadPicture(myfile)
    SavePicture Image1.Picture, bmp_dir & mybmpfile & ".bmp"
    myfile = Dir()
    Wend

    End Sub

    The test directory contains a few jpg, gif and bmp files.

    Hope this gives you a starting point. Note that I assumed that the file name contains only one period (.).

    Regards,

    Kevin Bell

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving a selected graphic as BitMap /BMP

    > Image control

    Thank you! This is just the start I needed, and your code ran flawlessly the first time.

  9. #9
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Saving a selected graphic as BitMap /BMP

    You are more than welcome Chris. Can you tell my boss that the code ran first time? It'll give him the heart attack he deserves. LOL

    Regards,

    Kevin Bell

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving a selected graphic as BitMap /BMP

    Sure. Pass on his email or telephone and I'll do it. You can get my email address from my web site.

    Code that runs right first time is a good goal. If nothing else it moves us towards (1) small chunks of code (the less moving parts there are, the less parts there are to go wrong) and (2) libraries of reusable code.

  11. #11
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving a selected graphic as BitMap /BMP

    Late this afternoon, your few lines of code mutated into a little application that allows you to nominate a source path and a target path, and then rips through ALL files in the source path and all subdirectories creating bitmaps from each available file.

    Non-image files are skipped.

    Bitmaps are numbered with four digits corresponding to minutes and seconds, e.g. 0000, 0001, 0002, ... 0059, 0100, 0101, ... 0159, 0200 up to 5959, at which time the hours kick in 10000,10001,10002 etc.

    You can nominate your CD drive as the source if you want to rip every available image off a CD. Or a colelction of CDs that are lying around and who-knows-what-they-contain, right?

    In an earlier post I showed my Wallpaper.bat file. That copies a bitmap file over Daily.bmp, which is assigned as the desktop wallpaper. Wallpaper.bat uses the minutes and seconds of the system clock to identify a bitmap soiurce file.

    So, with a shortcut to Wallpaper.bat on my desktop, I can reset the desktop wallpaper anytime i want. My boot sequence invokes Wallpaper.bat, so a re-boot gives me a different wallpaper.

    I modified the wallpaper.bat to create (by Echo) a small batch file that would DELETE the current ly assigned wallpaper file, so if I get a wallpaper I don't want anymore, I just double-click on the erase-wallpaper icon, and that file (e.g. 1347.bmp) is gone for good.

    Leaving a hole in the sequence.

    But not to worry. As the little appliaction is creating new bitmap files, it fills in any holes in the sequence before adding to the end.


    Anyay, thanks again.

    I'm a happy camper.

  12. #12
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Saving a selected graphic as BitMap /BMP

    As an aside to this thread but a related topic. Does anybody know how to invoke the built-in Graphics Converters in Office from VB or VBA?

    Just my devious mind I suppose, I'm thinking of how to go the other way, from .BMP to other graphics formats without resorting to third party software. I know there is a lot of freeware out there that'll probably do the trick but Enquiring Minds Just Have To Know.

    Regards,

    Kevin Bell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •