|
-
May 27th, 2005, 11:22 AM
#1
Thread Starter
Lively Member
Printscreen & Then Save JPG
how i would save my screen as a Jpg image ...
the quality of the jpg is 50%
Last edited by ayman_rapper; May 27th, 2005 at 12:34 PM.
-
May 27th, 2005, 04:03 PM
#2
Re: Printscreen & Then Save JPG
dunno about the print screen. But to save a jpeg with a certain quality:
Code:
/// <summary>
/// Only for JPEG format.
/// </summary>
/// <param name="quality">from 0 to 100.</param>
public static void GetImgQualityParams (int quality, out ImageCodecInfo imageCodec, out EncoderParameters encoderParams)
{
if (quality<0 || quality>100)
throw new ArgumentOutOfRangeException("quality must be between 0 and 100.");
// Get an array of ImageEncoders.
ImageCodecInfo[] imgCodecs = ImageCodecInfo.GetImageEncoders();
encoderParams = new EncoderParameters(1);
EncoderParameter imgQuality =
new EncoderParameter (Encoder.Quality, quality);
// Set the quality
encoderParams.Param[0] = imgQuality;
// JPEG format is index 1
imageCodec = imgCodecs[1];
}
you have that function and as an example you could use it like this:
Code:
Image img = img.FromFile ("c:\\whatnot.bmp");
ImageCodecInfo codecInfo=null;
EncoderParameters encoderParams=null;
GetImgQualityParams (batchInfo.JpegQuality, out codecInfo, out encoderParams);
img.Save ("C:\\whatnot.jpg", codecInfo, encoderParams);
hope it helps
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
May 28th, 2005, 06:56 AM
#3
Thread Starter
Lively Member
Re: Printscreen & Then Save JPG
Error 1 The type or namespace name 'ImageCodecInfo' could not be found (are you missing a using directive or an assembly reference?)
Error 2 The type or namespace name 'EncoderParameters' could not be found (are you missing a using directive or an assembly reference?)
-
May 28th, 2005, 04:04 PM
#4
Re: Printscreen & Then Save JPG
learn to use the Object Browser in vs.net, it's helpful
you need to import a namespace:
put this at the top of the code
using System.Drawing.Imaging;
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
May 29th, 2005, 07:00 AM
#5
Thread Starter
Lively Member
Re: Printscreen & Then Save JPG
Still there are some problems ...
pls attach a sample for the code ..
and thank u .........
-
May 29th, 2005, 09:03 PM
#6
Re: Printscreen & Then Save JPG
You can try this line of code to get a screenshot:
VB Code:
SendKeys.Send("+({PRTSC})");
which sends the keystroke combination Shift+PrintScreen to your application. This should capture the entire screen. If you want just your app window, try this instead:
VB Code:
SendKeys.Send("{PRTSC}");
You can then access the image via the clipboard. Lookup the Clipboard class in the help to learn how to retrieve the image.
-
May 30th, 2005, 02:20 PM
#7
-
May 30th, 2005, 03:17 PM
#8
Thread Starter
Lively Member
Re: Printscreen & Then Save JPG
-
May 30th, 2005, 11:48 PM
#9
Re: Printscreen & Then Save JPG
see this for capturing the screen, if you want to do it the "right" way. it uses windows API calls:
http://www.developerfusion.com/show/4630/
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
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
|