how i would save my screen as a Jpg image ...
the quality of the jpg is 50%
Printable View
how i would save my screen as a Jpg image ...
the quality of the jpg is 50%
dunno about the print screen. But to save a jpeg with a certain quality:
you have that function and as an example you could use it like this: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];
}
hope it helps :)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);
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?)
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;
Still there are some problems ...
pls attach a sample for the code ..
and thank u .........
You can try this line of code to get a screenshot: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.VB Code:
SendKeys.Send("{PRTSC}");
sendkeys is SLIGHLY stupid as it makes you modify your clipboard to get the screenshot. But if you don;t know any other way then I guess that's it :D
here's a sample project:)
thanks
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/