/[cvs]/joko/Uni/BSArch/04/bmp_fractal.c
ViewVC logotype

Diff of /joko/Uni/BSArch/04/bmp_fractal.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by joko, Sat Jul 1 11:45:35 2006 UTC revision 1.5 by joko, Sat Jul 1 12:19:46 2006 UTC
# Line 95  void write_blank_file(char *filename) { Line 95  void write_blank_file(char *filename) {
95    
96    
97  int main(int argc, char *argv[]) {  int main(int argc, char *argv[]) {
   int len,x,y;  
   char bgr[3];  
   short svalue;  
   int lvalue;  
98    
99      // MMF support
100      DWORD err;
101    HANDLE hMap, hFile;    HANDLE hMap, hFile;
   DWORD err, size;  
   int elems;  
     
102    LPVOID pData;    LPVOID pData;
103    unsigned char *pDataBitmap, *pDataBitmapCurrent;    unsigned char *pDataBitmap, *pDataBitmapCurrent;
104    
105      // workers
106      unsigned int workers = 3;
107      unsigned int worker_index, worker_rows, worker_startrow;
108      
109      // fractal calculation
110      int x, y;
111      char bgr[3];
112        
   int offset;  
113        
114    // create empty file (black background)    // create empty bmp-file (black background)
115    write_blank_file("test.bmp");    write_blank_file("test.bmp");
     
116    
117    /* open file for reading and writing */    /* open file for reading and writing */
118    hFile = CreateFile("test.bmp", GENERIC_WRITE|GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);    hFile = CreateFile("test.bmp", GENERIC_WRITE|GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
# Line 152  int main(int argc, char *argv[]) { Line 153  int main(int argc, char *argv[]) {
153    }    }
154    */    */
155    
156      // calculate segments of bitmap for worker threads/processes
157      worker_rows = YSIZE / workers;
158      printf("rows for each worker: %i\n", worker_rows);
159      for (worker_index = 0; worker_index < workers; worker_index++) {
160        
161        // number of row to start for each worker
162        worker_startrow = worker_index * worker_rows;
163        
164        // recalculate number of rows for last worker if (YSIZE mod workers) != 0
165        if (worker_index == workers - 1) {
166          worker_rows = YSIZE - worker_startrow;
167          printf("rows for last worker: %i\n", worker_rows);
168        }
169      }
170    
171    // calculate fractal    // calculate fractal
172    for (y=YSIZE-1; y>=0; y--) {    for (y=YSIZE-1; y>=0; y--) {
173            for (x=0; x<XSIZE; x++) {            for (x=0; x<XSIZE; x++) {
# Line 161  int main(int argc, char *argv[]) { Line 177  int main(int argc, char *argv[]) {
177              //printf("pointer: %p\n", pDataBitmapCurrent);              //printf("pointer: %p\n", pDataBitmapCurrent);
178                            
179              // transfer color values to current pixel              // transfer color values to current pixel
             //*pDataBitmapCurrent = (unsigned char *)bgr;  
180              pDataBitmapCurrent[0] = bgr[0];              pDataBitmapCurrent[0] = bgr[0];
181              pDataBitmapCurrent[1] = bgr[1];              pDataBitmapCurrent[1] = bgr[1];
182              pDataBitmapCurrent[2] = bgr[2];              pDataBitmapCurrent[2] = bgr[2];

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.5

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed