Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Image: public AbstrImage {
- private:
- int width, height;
- int depth, dpi;
- friend Slide;
- public:
- // Конструкторы
- Image();
- Image(Image &I);
- Image(Image *pI);
- Image(const char *Name, int Width, int Height, int Depth = 32, int Dpi = 96);
- ~Image();
- // Оператор присваивания
- void operator =(Image &I);
- // Виртуальные методы
- virtual int classType() { return ImageClass; }
- virtual char* className() { return "Image"; }
- virtual void printOn(ostream &out);
- // Методы
- void setName(const char *Name);
- void setSize(int Width, int Height) { width = Width; height = Height; }
- void setDepth(int Depth) { depth = Depth; }
- void setDpi(int Dpi) { dpi = Dpi; }
- void setAll(const char *Name, int Width, int Height, int Depth, int Dpi)
- { this->setName(Name); this->setSize(Width, Height); this->setDepth(Depth); this->setDpi(Dpi); }
- const char *getName() { return (const char *)name; }
- int getWidth() { return width; }
- int getHeight() { return height; }
- int getDepth() { return depth; }
- int getDpi() { return dpi; }
- int getNo() { return no; }
- };
- Image::Image():AbstrImage() {
- name = (char *)NULL;
- width = NULL, height = NULL;
- depth = NULL, dpi = NULL;
- }
- Image::Image(Image &I):AbstrImage() {
- no = 0;
- if(I.name != (char *)NULL) {
- name = new char[strlen(I.getName()) + 1];
- strcpy_s(name, strlen(I.getName()) + 1, I.getName());
- } else
- name = (char *)NULL;
- width = I.width, height = I.height;
- depth = I.depth, dpi = I.dpi;
- }
- Image::Image(Image *pI):AbstrImage() {
- no = 0;
- if(pI->name != (char *)NULL) {
- name = new char[strlen(pI->getName()) + 1];
- strcpy_s(name, strlen(pI->getName()) + 1, pI->getName());
- } else
- name = (char *)NULL;
- width = pI->width, height = pI->height;
- depth = pI->depth, dpi = pI->dpi;
- }
- Image::Image(const char *Name, int Width, int Height, int Depth = 32, int Dpi = 96) {
- no = 0;
- if(Name != (char *)NULL) {
- name = new char[strlen(Name) + 1];
- strcpy_s(name, strlen(Name) + 1, Name);
- } else
- name = (char *)NULL;
- width = Width, height = Height;
- depth = Depth, dpi = Dpi;
- }
- void Image::operator =(Image &I) {
- no = 0;
- if(I.name != (char *)NULL) {
- name = new char[strlen(I.getName()) + 1];
- strcpy_s(name, strlen(I.getName()) + 1, I.getName());
- } else
- name = (char *)NULL;
- width = I.width, height = I.height;
- depth = I.depth, dpi = I.dpi;
- }
- void Image::printOn(ostream &out) {
- out << "Номер в списке: " << no;
- if(name != (char *)NULL)
- out << " Название: " << name << endl;
- else
- out << " Название не задано" << endl;
- out << " Размеры изображения: " << width << "x" << height << endl;
- out << " Глубина цвета: " << depth << endl << " Точек на дюйм: " << dpi << endl;
- }
- void Image::setName(const char *Name) {
- if(name != NULL) delete[] name;
- if(Name != (char *)NULL) {
- name = new char[strlen(Name) + 1];
- strcpy_s(name, strlen(Name) + 1, Name);
- } else
- name = (char *)NULL;
- }
Add Comment
Please, Sign In to add comment