|
-
Dec 29th, 2001, 11:54 PM
#1
Thread Starter
Junior Member
Image Stuff
Hi,
Ive been searching numerous sites as well as here and havent found anything.
I want to know how i can resize an image and save it in the new dimensions as well. Also maintaining some of the quality.
ALso, how can i save images from a picture box as either a gif or jpeg, which currently arent supported
Thanks
-
Dec 30th, 2001, 12:03 AM
#2
Good Ol' Platypus
You can use the BitBlt API of a picture, refresh said picture, and SavePicture the .Image property.
Here's my tut on BitBlt:
http://vbden.tripod.com/articles/invmask.htm
To save Gifs and I believe JPEGs too, you can download controls from http://www.vbaccelerator.com/.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Dec 30th, 2001, 12:17 AM
#3
Thread Starter
Junior Member
Thanks for the links
while scanning through your tutorial i think noticed an eror
VB Code:
Function sCopy(SrcDC as Long, DstDC as Long, dW as Long, dH as Long, X as Long, Y as Long) as Long
sCopy = BitBlt(DstDC, X, Y, dW, dH, SrcDC, 0, 0, SRCCOPY
End Function
should be
VB Code:
Function sCopy(SrcDC as Long, DstDC as Long, dW as Long, dH as Long, X as Long, Y as Long) as Long
sCopy = BitBlt(DstDC, X, Y, dW, dH, SrcDC, 0, 0, SRCCOPY[b])[/b]
End Function
The change is outlined in bold....
I dont fully understand it, so if you could provide me with some an example of how to resize the image i would be greatly appreciated
Thanks for the response
-
Dec 30th, 2001, 12:28 AM
#4
Good Ol' Platypus
Whoops sorry I made a mistake there! Two actually! I'm rewriting the tutorial in a bit so it won't matter, thanks for pointing that out though.
Not in the code, but with what I told you... BitBlt doesn't stretch. StretchBlt is one of the sister APIs that I mentioned. It takes two other commands:
StretchBlt Dest DC, X, Y, Width, Height, Source DC, X, Y, SourceWidth, SourceHeight, Raster Operation
So for example, let's resize an image. Set the AutoSize to True and the ScaleMode to 3 - Pixels.
Now, to resize this to say, 50% of the image in both directions, we'll use this code. By the way, make sure you have another picutrebox called FiftyPercent.
VB Code:
StretchBlt FiftyPercent.hDC, 0, 0, Original.ScaleWidth * 0.5, Original.ScaleHeight * 0.5, Original.hDC, 0, 0, Original.ScaleWidth, Original.ScaleHeight, vbSrcCopy
FiftyPercent.Refresh
SavePicture FiftyPercent.Image, "C:\Fifty Percent.bmp"
That should all work out. It's a nasty looking resize but it does the job nonetheless.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Dec 30th, 2001, 12:36 AM
#5
Thread Starter
Junior Member
oh ok, thanks for the help!
I had a look through http://www.vbaccelerator.com/ but i only found something to save as JPEG and it also requires another dll or ocx...
Right now im having a look through freevbcode and vbcode but arent having much luck, i am going to try planet source code after this. But if you know of anywhere else, can you please tell me, i cant think of anything else
-
Dec 30th, 2001, 12:49 AM
#6
Thread Starter
Junior Member
Also, what function (and the syntax for it) to i have to declare for StretchBlt (just the parameters for it).
Thanks
-
Dec 30th, 2001, 01:14 AM
#7
Thread Starter
Junior Member
ok, i got it, but it wont work..
here is what im using
VB Code:
Set Picture1.Picture = CaptureScreen()
StretchBlt picResized.hdc, 0, 0, picResized.ScaleWidth, picResized.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbSrcCopy
picResized.Refresh
Picture1 receives the screen capture correctly but when i do the StretchBlt stuff, it doesnt put it into picResized, and it stays blank
lol, thanks for this
-
Dec 30th, 2001, 11:45 AM
#8
Good Ol' Platypus
Take out the refresh, I dunno, let me fire up VB and give you some working code.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Dec 30th, 2001, 11:48 AM
#9
Good Ol' Platypus
Yeah, that's it, just take out the refresh and it'll work itself out. Dunno what I was thinking...
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Dec 30th, 2001, 12:31 PM
#10
Good Ol' Platypus
I heavily modified a piece of code from Rod Stephen's Visual Basic Graphics Programming book that I have. I've also implemented StretchBlt so you can see the difference.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
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
|