comparison mac/dw.m @ 1176:408ea33b19cf

Ok fixed a problem with the last commit using the wrong representation on Mac. This shows that the problem was in fact the flipped image but the image view still seems to be printing oddly... but at least the important stuff is there now.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 19 Sep 2011 19:48:23 +0000
parents eb4589ddff3e
children 76262040ed5f
comparison
equal deleted inserted replaced
1175:eb4589ddff3e 1176:408ea33b19cf
9404 return result; 9404 return result;
9405 9405
9406 /* Figure out the printer/paper size */ 9406 /* Figure out the printer/paper size */
9407 pi = p->pi; 9407 pi = p->pi;
9408 size = [pi paperSize]; 9408 size = [pi paperSize];
9409 /* Okay the size reported is really small... and everything
9410 * in Cocoa is scaled so ... multiply by 2 to get a better
9411 * resolution but maintain the right aspect ratio.
9412 */
9413 size.width *= 2;
9414 size.height *= 2;
9409 /* Create an image view to print and a pixmap to draw into */ 9415 /* Create an image view to print and a pixmap to draw into */
9410 iv = [[NSImageView alloc] init]; 9416 iv = [[NSImageView alloc] init];
9411 pixmap = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8); 9417 pixmap = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8);
9412 rep = pixmap->image; 9418 rep = pixmap->image;
9413 pixmap2 = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8); 9419 pixmap2 = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8);
9417 * to go into the image view. 9423 * to go into the image view.
9418 */ 9424 */
9419 image = [[NSImage alloc] initWithSize:[rep size]]; 9425 image = [[NSImage alloc] initWithSize:[rep size]];
9420 flipped = [[NSImage alloc] initWithSize:[rep size]]; 9426 flipped = [[NSImage alloc] initWithSize:[rep size]];
9421 [image addRepresentation:rep]; 9427 [image addRepresentation:rep];
9422 [flipped addRepresentation:pixmap->image]; 9428 [flipped addRepresentation:rep2];
9423 [iv setImage:flipped]; 9429 [iv setImage:flipped];
9424 [iv setImageScaling:NSScaleProportionally]; 9430 [iv setImageScaling:NSScaleProportionally];
9425 [iv setFrameOrigin:NSMakePoint(0,0)]; 9431 [iv setFrameOrigin:NSMakePoint(0,0)];
9426 [iv setFrameSize:size]; 9432 [iv setFrameSize:size];
9427 9433
9447 { 9453 {
9448 /* Call the application's draw function */ 9454 /* Call the application's draw function */
9449 p->drawfunc(print, pixmap, x, p->drawdata); 9455 p->drawfunc(print, pixmap, x, p->drawdata);
9450 /* Internal representation is flipped... so flip again so we can print */ 9456 /* Internal representation is flipped... so flip again so we can print */
9451 _flip_image(image, rep2, size); 9457 _flip_image(image, rep2, size);
9458 #ifdef DEBUG_PRINT
9452 /* Save it to file to see what we have */ 9459 /* Save it to file to see what we have */
9453 NSData *data = [rep2 representationUsingType: NSPNGFileType properties: nil]; 9460 NSData *data = [rep2 representationUsingType: NSPNGFileType properties: nil];
9454 [data writeToFile: @"print.png" atomically: NO]; 9461 [data writeToFile: @"print.png" atomically: NO];
9462 #endif
9455 /* Print the image view */ 9463 /* Print the image view */
9456 [po runOperation]; 9464 [po runOperation];
9457 /* Fill the pixmap with white in case we are printing more pages */ 9465 /* Fill the pixmap with white in case we are printing more pages */
9458 dw_color_foreground_set(DW_CLR_WHITE); 9466 dw_color_foreground_set(DW_CLR_WHITE);
9459 dw_draw_rect(0, pixmap, TRUE, 0, 0, (int)size.width, (int)size.height); 9467 dw_draw_rect(0, pixmap, TRUE, 0, 0, (int)size.width, (int)size.height);