?
Solved

PaintPicture problem

Posted on 1998-06-11
9
Medium Priority
?
279 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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
Course of the Month15 days, 1 hour left to enroll

770 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