how to print saved images in vb6

I am having tiff images(front and rear images) in vb6 application. I am saving the tiff images to my local folder from fim and rim files and from there i am trying to print images.

Initially i tried to load the images to picturecox and tried to print the images, but tiff images are not able to print in this way. i am getting an error as invalid Picture.
.bmp and .jpg are working fine.

If pblnFlipped Then
        Set frmnewimage.img.Picture = Nothing
        frmnewimage.img.Picture = LoadPicture(mstrRearTiffImageFile)
        Else
        Set frmnewimage.img.Picture = Nothing
        frmnewimage.img.Picture = LoadPicture(mstrFrontTiffImageFile)
        End If
        Printer.PaintPicture frmnewimage.img.Picture, 100, 100
        Printer.EndDoc


so i am saving the picture to my local. but i am not under standing how to print images directly from the saved images. Please help me.

Thanks in Advance!!!!






What I have tried:

If pblnFlipped Then
       Printer.PaintPicture mstrRearTiffImageFile, 10, 10
       Else
       Printer.PaintPicture mstrFrontTiffImageFile, 10, 10
       End If
       Printer.EndDoc


mstrRearTiffImageFile and mstrFrontTiffImageFile are strings(rear image and front image). it consist of images which i need to print. based upon the image type (pblnFlipped) i need print images.
Kumar DineshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Try this.

If pblnFlipped Then
    Printer.PaintPicture mstrRearTiffImageFile.Picture, 100, 100
Else
    Printer.PaintPicture mstrFrontTiffImageFile.Picture, 100, 100
End If
Printer.EndDoc

Open in new window

0
Kumar DineshAuthor Commented:
Hi @Martin.. i tried the above scenario as well but i am getting compilation as invalid qualifier at  mstrRearTiffImageFile
0
Martin LissOlder than dirtCommented:
It turns out that VB6 can't handle tif/tiff files. Here is a suggestion/code that I found on the web.
Visual basic 6 doesn't support “*.tif” files.
Visual basic 6 loads pictures in image or picture box controls.
And loads only pictures with the: “*.bmp”, “*.cur”, “*.dib”,“*.emf”, “*.gif”,“*.ico”, “*.jpg” or  “*.wmf” extensions.

You have to change extension from “*.tif” to for example “*.bmp” (how to do that: open “*.tif” file with “Paint” and Save As like “*.bmp” file) and then put into your VB project:
For example:
1. ImgMyPicture.Picture = LoadPicture(App.Path & "\OnePicture.bmp")
‘one way
2. Or in design mode, load the picture, in image or picture box
controls, in their properties.  - other way

For printing image files VB6 uses Printer object and
PaintPicture method for example:


Sub PrintPictires()
Dim c As Control

For Each c In Controls
   If TypeOf c Is Image Then
  
        Printer.CurrentX = c.Left
        Printer.CurrentY = c.Top
        
        Printer.PaintPicture c.Picture, c.Left, c.Top
    End If

  If TypeOf c Is PictureBox Then
  
        Printer.CurrentX = c.Left
        Printer.CurrentY = c.Top
        
        c.AutoSize = True
        c.Refresh
        c.AutoSize = False
        
        Printer.PaintPicture c.Picture, c.Left, c.Top

    End If

Next c

Printer.EndDoc

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

ArkCommented:
Public Sub PrintTiff(ByVal path As String)
   Dim wiaImg As Object
   Set wiaImg = CreateObject("WIA.ImageFile")
   wiaImg.LoadFile path
   wiaImg.ActiveFrame = 1
   Printer.PaintPicture wiaImg.FileData.Picture, 100, 100
  'Set Picture1.Picture = wiaImg.FileData.Picture
End Sub

Open in new window

0
Martin LissOlder than dirtCommented:
I'm sorry Ark, but as written your code produces an "ActiveX component can't create object" error so it looks like something needs to be changed to allow it to work, and until that's done I don't think that your solution should be awarded points.
0
ArkCommented:
WIA is Microsoft Windows Image Acquisition platform starting from WinXP. But ImageFile object was introduced in WIA 2.0 which Microsoft claims starts from Vista, but all Win7 machines I tried does support this library.
Try this code on any Win7 or higher machine.

Regards
Ark
0
Martin LissOlder than dirtCommented:
Okay. I run Windows XP (as a virtual machine on my iMac) and since your explanation explains why it doesn't work for me I have closed the questions using the split suggested by MacroShadow.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.