Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Minor fix
[palacios.git] / linux_usr / vnc / Image.cxx
1 /* Copyright (C) 2002-2003 RealVNC Ltd.  All Rights Reserved.
2  *    
3  * This is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * 
8  * This software is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  * 
13  * You should have received a copy of the GNU General Public License
14  * along with this software; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
16  * USA.
17  */
18 //
19 // Image.cxx
20 //
21
22
23 #include <stdio.h>
24 #include <sys/types.h>
25 #include <sys/uio.h>
26 #include <sys/stat.h>
27 #include <sys/ipc.h>
28 #include <sys/shm.h>
29 #include <X11/Xlib.h>
30 #include <X11/Xutil.h>
31 #include <X11/extensions/XShm.h>
32 #include "Image.h"
33 #include <list>
34 #include <sys/ioctl.h>
35 #include <unistd.h> 
36 #include <fcntl.h>
37
38 class ImageCleanup {
39 public:
40   std::list<Image*> images;
41
42   ~ImageCleanup()
43   {
44     fprintf(stderr,"~ImageCleanup called\n");
45
46     while (!images.empty()) {
47       delete images.front();
48     }
49   }
50 };
51
52 ImageCleanup imageCleanup;
53
54 Image::Image(int width, int height)
55   : data(0)
56 {
57   data = new char[width*height*4];
58   
59   //default image will be three lines across the screen.
60   this->width = width;
61   this->height = height;
62   
63   for (int i = 0; i < width*(height/3)*4; i++) {
64     if ((i % 4) == 0){
65       data[i] = 255;
66     }
67   }
68   for (int i = width*(height/3)*4 + 1; i < width*(2*height/3)*4; i++) {
69     if (((i + 3) % 4) == 0){
70       data[i] = 255;
71     }
72   }
73   for (int i = width*(2*height/3)*4 + 1; i < width*(height)*4; i++) {
74     if (((i + 2) % 4) == 0){
75       data[i] = 255;
76     }
77   }    
78 }
79
80 Image::~Image()
81 {
82   delete [] data;
83 }
84