After I StretchBlt an image to a picture box, how can I save the strethed picture? I tried experimenting a little with the image property but I couldn't get it :(
Thanks
Printable View
After I StretchBlt an image to a picture box, how can I save the strethed picture? I tried experimenting a little with the image property but I couldn't get it :(
Thanks
Perhaps the following will do the job:
VB Code:
Private Sub Command1_Click() SavePicture Picture1.Picture, App.Path & "\mypicture.bmp" End Sub
That was my first guess too...if that doesn't work use BitBlt to Blt it to a new picture box (that one should now have the same size and, not be streched)..and then save it...
Thanks for the suggestion but it doesn't work... It shows an error. I tried using the Image property also but I just get a gray box saved... :( Any other ideas?
If I do a normal bitblt I will be able to save it?Quote:
Originally posted by NoteMe
That was my first guess too...if that doesn't work use BitBlt to Blt it to a new picture box (that one should now have the same size and, not be streched)..and then save it...
Quote:
Originally posted by manavo11
If I do a normal bitblt I will be able to save it?
It's my best shot right now...:D
Or you may have to use GetPixel and SetPixel..but I can't understand why taht should work any better then BitBlt...
Make sure Picture1.AutoRedraw = True.Quote:
Originally posted by manavo11
Thanks for the suggestion but it doesn't work... It shows an error. I tried using the Image property also but I just get a gray box saved... :( Any other ideas?
It seems it isn't working...
VB Code:
picTemp.Picture = Clipboard.GetData() StretchBlt picStretch.hdc, 0, 0, picTemp.ScaleWidth / 2, picTemp.ScaleHeight / 2, picTemp.hdc, 0, 0, picTemp.ScaleWidth, picTemp.ScaleHeight, vbSrcCopy picStretch.Height = picTemp.Height / 2 picStretch.Width = picTemp.Width / 2 Picture2.Width = picStretch.Width Picture2.Height = picStretch.Height BitBlt Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, picStretch.hdc, 0, 0, vbSrcCopy SavePicture Picture2.Image, "C:\test.bmp"
I'm trying to make it half size...
You don't need that second Blt...;)...
Yeah if you just Set AutoRedraw = True if works. :)
You don't even need any api to do that:
Also, open attachments for a sample projectVB Code:
Public Sub ZoomPicture(pct As PictureBox, zoom As Double) With pct .Width = .Width * zoom .Height = .Height * zoom .PaintPicture .Picture, 0, 0, .ScaleWidth, .ScaleHeight End With End Sub
Well, RhinoBull got it... It was the AutoRedraw... :D Thanks :afrog:
Not at all, but take a look at that sample I sent last time. :wave:
Seen as though you halfing the size it might be an idea to blur the image first so quality isn't lost so much. ;)
Thanks for that also, but making it half was just an example... Thanks anyway though ;)Quote:
Originally posted by RhinoBull
Not at all, but take a look at that sample I sent last time. :wave:
Blur it? :confused:Quote:
Originally posted by Electroman
Seen as though you halfing the size it might be an idea to blur the image first so quality isn't lost so much. ;)
Soften the edges....a lot of algorithms to do that....don't bother with it if this is just an example...
Simplest way is to just set each pixel to the average of itself and the surounding pixels, as NoteMe says theres not really any point if your just playing around to see what StretchBlt does :D.
That was the general idea... :D But, would I gain that much if I blurred it? And wouldn't it delay? :confused:Quote:
Originally posted by Electroman
if your just playing around to see what StretchBlt does :D.
Well when you use StretchBlt its like taking everyother pixel and using that, however this means if you use it on a grid and the lines on the grid are 1 think (and lie on the every other line) they will be lost or the other way round and they will appear as a solid color.
When you use the Blur first this means that a pixel on the missed out lines isn't forgotten because it has had an effect on the surrounding pixels.
There is a slight delay but it all depends on how big the picture is and what method you use. Some methods you wont even notice the delay.
Very interesting... :D Thanks for all the info :afrog: