|
-
August 24th, 2001, 05:46 AM
#1
Copying pictires
I'm working on a tool to allow 2 related bitmap images to be aligned to a common datum.
This involves rotating and re-sizing one of them.
My problem is that I am unable to copy the rotated image from one picturebox to another. when I try, I either get an "invalid image" error or - if I have previously loaded an image directly from file into the picturebox in which the rotation is performed, it is that image which gets copied.
Any help would be appreciated.
-
August 24th, 2001, 06:47 AM
#2
Re: Copying pictires
Look here: it is not directly the answer, but it may help you
http://codeguru.com/cgi-bin/bbs/wt/s...age=&view=&sb=
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
August 24th, 2001, 07:25 AM
#3
Re: Copying pictires
Thanks for the help, but this does not seem to address the problem.
From the symptoms, VB doesn't seem to recognise that the image in the picturebox which is being copied has been changed. I know for a fact that it is, because I can view it on the screen.
I'm using the point method to draw each pixel in the source picturebox
-
August 24th, 2001, 07:28 AM
#4
Re: Copying pictires
Sorry - I should have said I'm using the pset method to actually draw each pixel.
-
August 24th, 2001, 09:57 AM
#5
Re: Copying pictires
Well, I've found a work around, which still leaves me puzzled.
Although the copied image does not reflect the change, I can save it to file, then reload it into the destination picturebox from there.
How come it will save but not copy ??
Another Bill Gates wonder 
-
August 24th, 2001, 10:12 AM
#6
Re: Copying pictires
I do not rate you only because I am out of votes... Another way to do it is the following: using a printscreen (you can do this programmatically) to copy the contents on clipboard, and then copy the clipboard contents to the other picturebox.
In any case, your is a nice solution.
Have a nice day
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
August 24th, 2001, 10:15 AM
#7
Re: Copying pictires
After drawing the image into the pictureBox do this
Picture1.Picture = Picture1.Image
This creates the Picture from the Image
John G
-
August 24th, 2001, 10:24 AM
#8
So easy, so nice!
Great.
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
August 24th, 2001, 10:35 AM
#9
Re: Copying pictires
Yes !!
At last I've stumbled across this myself - I no longer need to save the image first.
Thanks to all of you who've helped here
-
August 25th, 2001, 12:35 AM
#10
Re: Copying pictires
Let's make things a bit more clearer so that you do not stumble later.
A picturebox or form etc have a picture property, and the picture that you assign to it stays permanently in it. For example, even the Cls method doesn't clear this. You must set the picture property explicitly to Nothing to remove this picture.
Above this is a "canvas" on which you can draw upon. The "canvas" is the Image property and it constitutes of the background image as well as any drawing you do on it. Remember that what you draw on it doesn't affect the picture property, only the image property.
If the Autoredraw property is False, then the canvas is directly upon the picture box, so if by any chance, the picturebox gets covered by something else, such as a popup window, then anything you've drawn on it is lost. However, if the Autoredraw property is set, the Image remains as a bitmap in memory, and so is not lost so easily as before.
Whenever you're dealing with the GDI API's, the Image is used, not the picture. But with Visual Basic functions, you can use either. If you're using the PaintPicture method, for example, you can use
Picture2.PaintPicture Picture1.Picture, 0, 0
or
Picture2.PaintPicture Picture1.Image, 0, 0
depending upon which "layer" you want to copy.
Similarly for the SavePicture API. However, the Picture property retains the file format, the image size as well as the resolution whereas the Image property is a bitmap with the resolution the same as the screen, and size as confined by the picturebox.
You can assign the Image property to the Picture property when needed as John suggested.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|