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}

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.

What about Managed C++. I am not sure, but it seems to have all the features that C# has. Correct me If I am wrong :)

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.

Well done, you've stumbled upon a specific case of the general guideline that one should use the best tool for the job. It's a shame that you derived a whole lot of crap out of it and then had the rocks to suggest that such obvious insights would bruise anyone's ego. :icon_rolleyes:

Yes, you can do that, but without C++, you lose all the fun and excitement of doing it. Also, this code is only for Windows. You should be able to do the same with WxWidgets, but with a bonus of cross-platformness. Or you can use Python.

Usually if I want to have fun programming, I use C++, where one wrong pointer, or counter variable that goes 1 over the limit of an array, crashes the program.

And if I want to actually DO something I use Python. I like Python, but it is just not "my" language, so when I have a chance, I always use C++.

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.

Since c++ is not a Microsoft product why would you expect the language to contain those things? C++ was not even invented by Microsoft. If you want all that support for Microsoft Office then use a different language which is designed for that purpose.

Since c++ is not a Microsoft product why would you expect the language to contain those things? C++ was not even invented by Microsoft. If you want all that support for Microsoft Office then use a different language which is designed for that purpose.

Expect? What are you daft? No, but they are useful features and their omission may potentially be leading to a decline in the use of C++, particularly (as stated previously) at least partially due in part to the features meeting the business needs of today.

Would you consider it a benefit for a useful feature to be included in the language's standard "library" ?

Expect? What are you daft? No, but they are useful features and their omission may potentially be leading to a decline in the use of C++, particularly (as stated previously) at least partially due in part to the features meeting the business needs of today.

Would you consider it a benefit for a useful feature to be included in the language's standard "library" ?

And tell us all why including Windows specific "features" would be of benefit to people using other platforms?

You're confusing the core language (C++) with a specific implementation of that language on a specific operating system (Visual C++).

To facilitate Windows users, Microsoft has created the Windows specific APIs and ships them with their implementation of the C++ language, which is Visual C++.
Borland did the same with their language implementations, so do others for their supported platforms.

And that's how things work in the real world, a world not ruled by little kids with no idea of how things work.

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

Since when did C++ become a Microsoft sole business, am sure you looked at it from just your side maybe because you're so used to the Microsoft platform and forgeting that C++ existed before the .NET framework incorporated it

As it stands I've made my point quite well, even if you should decide to misinterpret it.

Am sure you also misunderstood the author of this thread. Visual C++ was never mentioned.

http://lh6.ggpht.com/-IoO3eeZZi9E/Tk...2011-04-01.jpg

Well, I personally use Linux :)
The link you posted does not account the servers Linux, TVs, new refrigerators, PS3s, Microprocessors, cars and planes, super computers, Phones, and Tablet PCs. No-one misinterprets you, but we are just telling you there is things other then Windows.

Windows (as OS) and .NET are written in C++ and C, this functions you used are written in C++ lower-level API and just called from C#. So nothing can be made without C++. Some of the devices that use C and C++ don't even have screens, so how would the implement the screen-shots? You should care for all the programmers, not only about yourself, and this is what Dennis Ritchie and Bjarn Stroustrup did!

Well, I personally use Linux :)
The link you posted does not account the servers Linux, TVs, new refrigerators, PS3s, Microprocessors, cars and planes, super computers, Phones, and Tablet PCs. No-one misinterprets you, but we are just telling you there is things other then Windows.

Windows (as OS) and .NET are written in C++ and C, this functions you used are written in C++ lower-level API and just called from C#. So nothing can be made without C++. Some of the devices that use C and C++ don't even have screens, so how would the implement the screen-shots? You should care for all the programmers, not only about yourself, and this is what Dennis Ritchie and Bjarn Stroustrup did!

Sounds like more butthurt babbling because you don't want to hear that .NET is better for business.

commented: Why must you stoop to name-calling, a little defensive? +0
commented: ad-hominem attacks instead of arguments... +0

Sounds like more butthurt babbling because you don't want to hear that .NET is better for business.

Are you done insulting other people without an apparent reason? If you are, then I may discuss with you this subject further. If you do not have anything intelligent to say, then I am done here.

Are you done insulting other people without an apparent reason? If you are, then I may discuss with you this subject further. If you do not have anything intelligent to say, then I am done here.

It's just that the flock of naysayers aren't worth the time.

Yes, I completely agree now. You are not worth my time. You do not listen to what other people say, and when someone does not agree with you, you try to desperately defend your own opinion by insulting others.

I think this about sums things up:

Yes, I completely agree now. You are not worth my time. You do not listen to what other people say, and when someone does not agree with you, you try to desperately defend your own opinion by insulting others.

That is a lie, my interest in this thread just dropped to about zero when I noticed the flock of naysayers were about to drag this thread on for.foorking.ever.

well for me C++ is the basic of all. i would never learn such algorithms and logics without it in other languages.

I think this about sums things up:

ROLF I thought one of them was a troll

C++ will not and should not die because I just started learning it...

Then it will as long as you.

ROLF I thought one of them was a troll

I am not sure who I prefer being in this argument. I think I prefer being a calm camel, to being a screaming girl? I am not sure :D

commented: I prefer a camel :D +0

A language dies when the last programmer in it dies off, and even then, it lingers on for quite a while until all programs written in that language are still used. :-)

Languages never die off. My dad still uses 20 year old computer at work, he writes Pascal programs (he is a scientist).
I am learning Lisp right now. Lisp was made in 59 I think.
So I don't think any language that once was relatively popular and widely used will completely die off.

If i'm honest saying that C++ is dying is ridiculous. You look at any large scale business software and its most often coded in C/C++. Java is kinda the new kid on the block looking to compete with C++ but due to its infancy its still got a long way to go before it can look to kicking C++ out of the picture.

And do not ignore the user base. The more users, the longer it takes to 'die.'

Anybody who does ignore those geeks^H^H^H^H^H users will always wonder "How come they still use [C++, Visual Basic 6, TECO, Assembler, FORTRAN, COBOL,<insert your fave here>] at that place ?"

Legacy code = job security.:cool:

To kill a language, one has to actively make machines that work against it.

Yeah! I was going to mention the fact that COBOL is the worst language in the world and yet most internal software depends on it. It is one of those old, spaghetti-code languages that has about a billion person hours invested and limps along because -er- no one knows how it does what it does using computed goto statements for gawds sake.

Sigh

Yeah! I was going to mention the fact that COBOL is the worst language in the world and yet most internal software depends on it. It is one of those old, spaghetti-code languages that has about a billion person hours invested and limps along because -er- no one knows how it does what it does using computed goto statements for gawds sake.

Sigh

It's very obvious you have never studied COBOL with this asinine synopsis of the language. For what you want to do, it may be a bad language. But that is far from the truth. The reason it's still around is because it is a very good language for what it does and the arena it's used in. Believe me, if it was bad for the reasons you stated, it would have been replaced long ago. The fact that it's hasn't been shows it's usefulness.

Even the (IMO) gawd-awful RPG language, it does what it's supposed to. Effectively.

commented: Soo true +0

I agree. Loads of "real" (post office, police, airlines, tax, whatever) code runs on ancient systems.

Doesnt your FBI datbase run on dumb terminals off old System/360s. Cost ~400 million in *1967 dollars*, i believe. Same with the HMRC (Our version of the IRS). It is running all of our taxes on an ancient ICL (Fujitsu)on 19870s/80s pieces of big iron. Millions and millions of lines of ALGOL code.

This is still being manintained and written. Languages dont die. Or shall we just spend many many millions rewriting the foundation of our enconomy each time a new language appears?, or hoping that if we do so some criminals dont slip through the net? Or shall we just stick with what works... If it aint broke dont fix it....

commented: yep +0

Cobol runs on Windows 7, Linux, and the current leading edge IBM Mainframes. So why are you implying only ancient systems? It is still being used and developed in many companies -- not just being maintained because they can't rewrite the code.

Cobol is still the spine and nervous system of many companies -- Fortune 500 included.

Dont misunderstand me Walt, I wasnt implying it was in any way obsolete. i was just using the fact that older hardware is in use to prove my point that systems in general dont die when the next best thing comes along, and to further my "if it aint broke dont fix it" analogy.

Ahh, OK.

By the way, see this and this

commented: Time for me to start learning Cobol +0

If i'm honest saying that C++ is dying is ridiculous. You look at any large scale business software and its most often coded in C/C++. Java is kinda the new kid on the block looking to compete with C++ but due to its infancy its still got a long way to go before it can look to kicking C++ out of the picture.

LOLOLOLOL

Been using Java prodessionally since 1997, on enterprise level applications.
To say Java is "the new kid on the block" and not used for "large scale business software" just shows your ignorance of the field.

Not to say C++ isn't used any longer, for it is, but it's certainly no longer the first choice for many of the largest corporate and government entities when creating new systems (especially middleware and backend systems).

commented: tyvm +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.