Well since I got in a little late I'll spare no other's ego any expense.
C++ still has the same drawbacks it's always had since I've been programming, and it's very nature implies that it doesn't have a built-in Microsoft Word file format interpreter that gets updated every time M$ releases a new version, it doesn't have a built-in IE based Web Browser for browser automation tasks, and it doesn't have a built-in Microsoft copyright logo creator.
C++ is great because it's flexible, but RAD tools seem to be the way of business needs these days. If you knew C++ and C# and had to, say.. Capture a portion of the screen and compress it as a jpeg and reduce the quality to 50% to reduce the file size (for scraping needs or something), which language would you rather use?
If the built-in .NET framework classes/methods didn't do what you wanted, then and only then would you most likely be using C++ as long as performance isn't a concern.
Speaking from a noob's standpoint, knowing very very little about screen capture and absolutely nothing about jpeg compression I must say C# is the correct language to use.
//GetScreen.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.IO;
namespace ScreenCapture
{
public class GetScreen
{
private Graphics gfx;
private Bitmap bmp;
private Point zero;
private Size resolution;
private Size imgSz;
public GetScreen()
{
zero = new Point(0, 0);
resolution = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height,
PixelFormat.Format32bppArgb);
gfx = Graphics.FromImage(bmp);
imgSz = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
}
~GetScreen()
{
bmp.Dispose();
gfx.Dispose();
}
public Bitmap GetWholeScreen()
{
gfx.CopyFromScreen(zero, zero, resolution);
return new Bitmap(bmp, imgSz);
}
public Bitmap GetImageCopy(Point topLeft, Size widthHeight)
{
gfx.CopyFromScreen(zero, zero, resolution);
return bmp.Clone(new Rectangle(topLeft, widthHeight), PixelFormat.DontCare);
}
public void SaveBitmapAsJpeg(Bitmap someBitmap, long qualityPercentage, string fileName)
{
if (someBitmap == null || fileName == null)
{
throw new ArgumentNullException();
}
if (qualityPercentage > 100 || qualityPercentage < 0)
{
throw new ArgumentException("Argument qualityPercentage was out of bounds. 0-100 is supported.");
}
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
ImageCodecInfo ici = null;
foreach (ImageCodecInfo codec in codecs)
{
if (codec.MimeType == "image/jpeg")
{
ici = codec;
break;
}
}
EncoderParameters ep = new EncoderParameters();
//0 = lowest quality, 100 = highest.
ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)qualityPercentage);
someBitmap.Save(fileName, ici, ep);
}
public void SaveBitmapAsJpeg(Bitmap someBitmap, long qualityPercentage, Stream st)
{
if (someBitmap == null || st == null)
{
throw new ArgumentNullException();
}
if (qualityPercentage > 100 || qualityPercentage < 0)
{
throw new ArgumentException("Argument qualityPercentage was out of bounds. 0-100 is supported.");
}
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
ImageCodecInfo ici = null;
foreach (ImageCodecInfo codec in codecs)
{
if (codec.MimeType == "image/jpeg")
{
ici = codec;
break;
}
}
EncoderParameters ep = new EncoderParameters();
//0 = lowest quality, 100 = highest.
ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)qualityPercentage);
someBitmap.Save(st, ici, ep);
}
}
}
The day C++ has a standard library like this, is the day high-performance low-maintenance adaptive software is commonplace for the Windows environment (never, in other words).
Another beautiful view from the top of the .NET mountain is that you can write native code using C++ or C, wrap it in a C++/CLI class compiled as a class library and use it from C# or VB or F#. {:D}