|
-
Jun 10th, 2002, 09:34 AM
#1
saving image to jpeg and resizing... works but...
Previously in VB6 I managed to hook into a DLL created from the Intel graphics library.
I had a speedy way to create thumbnails and to save a loaded images to a jpeg file where I can set the quality and other attributes.
Now in vb.net this is very simple withbuilt in methods but...
i) I do not know what type of sampling the thumbnail uses as the Intel library had a few choices depending on a tradeoff between speed and quality.
ii) The jpeg save justs saves but does not seem to offer a control over the quality.
Q. Is there a way to set the quality or other parameters when saving?
There seems to be a lack of documentation or examples around that do any more than the basics.
-
Jun 10th, 2002, 09:47 AM
#2
yeah using EncoderParameters
Code:
Dim imgCodecs() As ImageCodecInfo = ImageCodecInfo.GetImageEncoders()
Dim params As New EncoderParameters = EncoderParameters(1)
Dim quality As New EncoderParameter EncoderParameter(Encoder.Quality, 50)
'Set quality to 50
params.Param(0) = quality
yourimage.Save("c:\output.jpg",imgCodecs(1), params)
btw imgCodecs(1) means JPEG not sure what the other array values would be if you need other image types
-
Jun 10th, 2002, 09:58 AM
#3
oops..I knew I sghould have tested that...just kind of guessed..but there were some errors..here is the WORKING code
Code:
Dim imgCodecs() As ImageCodecInfo = ImageCodecInfo.GetImageEncoders()
Dim params As EncoderParameters = New EncoderParameters(1)
Dim quality As EncoderParameter = New EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 50)
'Set quality to 50
params.Param(0) = quality
newBitmap.Save("c:\blah.jpg", imgCodecs(1), params)
-
Jun 10th, 2002, 10:11 AM
#4
Thanks for the quick reply!
I had a feeling it was one of the other more complicated options.
In typical Microsoft fashion it can be done...if you know where to find it.
Would be nice if they had a few functions like
SaveAsJPG(name as string, quality as integer, descr as string, ...)
Maybe I'll just create such a function myself
-
Jun 10th, 2002, 10:16 AM
#5
well it is just that the EncoderParameter covers more than just JPegs..it was written that way to cover a wider range of use...BTW here are the other Parameters you can set
ChrominanceTable
ColorDepth
Compression
LuminanceTable
RenderMethod
SaveFlag
ScanMethod
Transformation
Version
I may look into wrapping all this stuff into a dll to make it easier when i get the time.
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
|