Thread: help me, i know this sounds crazy but i want to do it...

  1. #1
    Registered User madsmile's Avatar
    Join Date
    Feb 2002
    Posts
    26

    help me, i know this sounds crazy but i want to do it...

    I got this:

    i'm working on borland C++ v3.1
    i'm working with graphics.h
    what i want is do capture the background into a matrix (dynamic memory) then draw some stuff over the captured area, and then i want to restore the backgound... but i get a strange result, maybe this code is wrong... i got ir from here in a question i made a couple of days ago...


    Code:
    class backgrnd{
      protected:
        int** matrix;
        int x1, y1,
    	x2, y2;
      public:
         backgrnd(int, int, int, int);
         ~backgrnd();
    };
    
    backgrnd::backgrnd(int bx1, int by1, int bx2, int by2)
    {
     x1 = bx1; y1 = by1;
     x2 = bx2; y2 = by2;
     int i;
     int* column;
    
     matrix = new int*[y2-y1];
     for (i = 0; i < y2-y1; i++)
       matrix[i] = new int[x2-x1];
    
     for (i = 0; i < (x2-x1); i++)
       {
        column = matrix[i];
        for (int j = 0; j < (y2-y1); j++)
          column[j] = getpixel(i+x1,j+y1);
        }
    }
    
    backgrnd::~backgrnd(void)
    {
     int* column;
     for (int i = 0; i < (x2-x1); i++)
       {
        column = matrix[i];
        for (int j = 0; j < (y2-y1); j++)
          putpixel(i+x1,j+y1,column[j]);
        }
     delete []matrix;
    }
    
    void main (void)
    {
    //here i open borland BGI with initgraph(); 
    
    
     backgrnd *b = new backgrnd(270,100,400,400); 
    // here i draw a some stuff
     delete b;
     getch();
    
    //here i close borland BGI with closegraph(); 
    
    }
    MADSmile
    ICQ #3653692
    (i'm running Borlad C++ Ver 3.1 under MSDOS)

  2. #2
    Registered User madsmile's Avatar
    Join Date
    Feb 2002
    Posts
    26

    Lightbulb

    I want to know is there some other way to do it...
    MADSmile
    ICQ #3653692
    (i'm running Borlad C++ Ver 3.1 under MSDOS)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sounds in game
    By Gordon in forum Windows Programming
    Replies: 7
    Last Post: 10-07-2008, 10:14 AM
  2. Replies: 7
    Last Post: 06-20-2003, 12:05 PM
  3. Sounds
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 04-17-2003, 06:27 AM
  4. crazy
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 08-31-2002, 08:54 PM
  5. Sounds, or no sounds?
    By face_master in forum C++ Programming
    Replies: 3
    Last Post: 09-03-2001, 05:29 PM