I want to draw a big white square with a small black square in the center and then get each pixel value in array form. Can I draw it using C++? Or, I should import the picture from another file and then get each pixel value of its pixel. But, again how can I do that?
Thank you for your help...
Three answers:
anonymous
2008-12-23 19:25:16 UTC
C++ does not provide graphics capability as a part of the language's standard library. If you're completely lost in this regard, then I'd advise you to choose another, higher-level language.
Gee
2008-12-24 03:26:15 UTC
Hi ming
the answer sis easy.. review the below code
* Object Orientation in C++ */
#include
/* abstract interface declaration */
class Shape
{
public:
virtual void Draw () = 0;
virtual void MoveTo (int newx, int newy) = 0;
virtual void RMoveTo (int dx, int dy) = 0;
};
/* Class Rectangle */
class Rectangle : public Shape
{
public:
Rectangle (int x, int y, int w, int h);
virtual void Draw ();
virtual void MoveTo (int newx, int newy);
virtual void RMoveTo (int dx, int dy);
virtual void SetWidth (int newWidth);
virtual void SetHeight (int newHeight);
private:
int x, y;
int width;
int height;
};
void Rectangle::Draw ()
{
cout << "Drawing a Rectangle at (" << x << "," << y