Changeset 461
- Timestamp:
- Jun 5, 2006, 6:42:59 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/vizservers/nanovis/nanovis.cpp
r458 r461 2178 2178 2179 2179 2180 #if DO_RLE 2180 2181 char rle[512*512*3]; 2181 2182 int rle_size; … … 2211 2212 } 2212 2213 } 2214 #endif 2213 2215 2214 2216 // used internally to build up the BMP file header … … 2231 2233 header[pos++] = 'M'; 2232 2234 2235 // BE CAREFUL: BMP files must have an even multiple of 4 bytes 2236 // on each scan line. If need be, we add padding to each line. 2237 int pad = 0; 2238 if ((3*win_width) % 4 > 0) { 2239 pad = 4 - ((3*win_width) % 4); 2240 } 2241 2233 2242 // file size in bytes 2234 int fsize = win_width*win_height*3+ sizeof(header);2243 int fsize = (3*win_width+pad)*win_height + sizeof(header); 2235 2244 bmp_header_add_int(header, pos, fsize); 2236 2245 … … 2250 2259 bmp_header_add_int(header, pos, win_height); 2251 2260 2252 // 1 plane + 24 bits/pixel << 162261 // 1 plane + (24 bits/pixel << 16) 2253 2262 bmp_header_add_int(header, pos, 1572865); 2254 2263 … … 2269 2278 2270 2279 // BE CAREFUL: BMP format wants BGR ordering for screen data 2271 for (int i=0; i < 3*win_width*win_height; i += 3) { 2272 unsigned char tmp = screen_buffer[i+2]; 2273 screen_buffer[i+2] = screen_buffer[i]; 2274 screen_buffer[i] = tmp; 2280 unsigned char* scr = screen_buffer; 2281 for (int row=0; row < win_height; row++) { 2282 for (int col=0; col < win_width; col++) { 2283 unsigned char tmp = scr[2]; 2284 scr[2] = scr[0]; // B 2285 scr[0] = tmp; // R 2286 scr += 3; 2287 } 2288 scr += pad; // skip over padding already in screen data 2275 2289 } 2276 2290 … … 2280 2294 2281 2295 write(0, header, sizeof(header)); 2282 write(0, screen_buffer, 3*win_width*win_height);2296 write(0, screen_buffer, (3*win_width+pad)*win_height); 2283 2297 } 2284 2298
Note: See TracChangeset
for help on using the changeset viewer.