Solved

PaintPicture problem

Posted on 1998-06-11
9
273 Views
Last Modified: 2008-02-01
Hello all,

I am having a problem with the paintpicture method.  I load a picture file into a picturebox using the loadpicture method.
   set pic2.picture = loadpicture("c:\vermont.jpg")

Then I use the paintpicture method to paint the picture to another picturebox control.
   pic1.paintpicture pic2.picture, 0, 0, 1000, 1000

At this point the, although the picture paints on the screen, the picture property of pic1 is 0, the type property of pic1 is 0, indicating no picture.  So if I try to use another paintpicture, which is what I want to do to paint this to the printer object, I get an "invalid picture" error.
    printer.paintpicture pic1.picture 0, 0   ' results in error

Can anyone tell me why this is happening and what can be done about it?  I've tried using a .bmp file just to see if that was the problem, using the image property to work with the pictures (which does work and does print, but not what I want.  Either is doesn't size properly or prints in greyscale).

Thanks much
0
Comment
Question by:jamespaul
[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
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 4

Expert Comment

by:zsi
ID: 1463101
Try using the RasterOp vbSrcCopy.

Btw, you do know that you can simply do this?
   Set Picture2.Picture = Picture1.Picture

Or, are your needs more complex?

0
 

Author Comment

by:jamespaul
ID: 1463102
zsi,
Thanks for the comment.  I need to change the size of the image, then print it at that size.  You answered a question for me a couple of days ago about a richtextbox.  I'm trying to print id cards.   So not only do I need to move the picture from the TWAIN source, I need to size it and display it for the user to see, and print it and everything on the id card (which I'm hoping at this time can be a picturebox and the paintpicture method), including graphics and text.  This may not work well, as I'm not sure how the text will look and whether standard printer fonts will work better.  In that case I'll try the moveing the picture and text to the print object, but I don't know if it supports both text and graphics.  The printform method (if I change to a form) is done as a bitmap and the manual seems to recommend not using this.  I'll look up the function you mentioned and see if it fits my needs.  Thanks again.
0
 

Author Comment

by:jamespaul
ID: 1463103
Whoops, not a function.  I tried the vbSrcCopy with the paintpicture, but alas, to no avail.
Thanks for the suggestion.
0
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!

 
LVL 6

Accepted Solution

by:
clifABB earned 100 total points
ID: 1463104
Try using bitblt instead:
Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Dim lRes As Long

To Paint Picture from pic1 to pic2
  lRes = BitBlt(pic2.hDC, 0, 0, 1000 / Screen.TwipsPerPixelX, 1000 / Screen.TwipsPerPixelY, pic1.hDC, 0, 0, vbSrcCopy)

To Paint Picture from pic2 to printer
  lRes = BitBlt(Printer.hDC, 0, 0, 1000 / Screen.TwipsPerPixelX, 1000 / Screen.TwipsPerPixelY, pic2.hDC, 0, 0, vbSrcCopy)

0
 

Author Comment

by:jamespaul
ID: 1463105
Thanks clifABB,

I'll give it a shot.  I'm trying the StretchBlt function now, and if that doesn't work I'll try the other one you suggested.  But basically you answered my question and made me realize I need to use the API functions.  And gave me an idea of something to try to boot.
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1463106
StretchBlt() and BitBlt() are basically the same thing (a lot of the underlying code is mutual between the two).

Also, you may need to set the AutoRedraw property of the picturebox(s) to true
0
 
LVL 1

Expert Comment

by:winsumpu
ID: 1463107
Please show how to create a paintbrush look like program to edit ur bitmap file in VB 4.0 or lower.


0
 
LVL 6

Expert Comment

by:clifABB
ID: 1463108
winsumpu:
You need to post a new question for this, not tack on your request to someone else's question.
0
 
LVL 4

Expert Comment

by:zsi
ID: 1463109
please to be showing Photoshop how write filters in QBasic to.
0

Featured Post

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!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

730 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