Mercurial > dwindows
comparison mac/dw.m @ 1247:93607596cf85
Implemented dw_pixmap_stretch_bitblt() on Mac.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 19 Oct 2011 11:01:25 +0000 |
parents | 459426f31fb4 |
children | 61d0c5f84644 |
comparison
equal
deleted
inserted
replaced
1246:c228c90f95cb | 1247:93607596cf85 |
---|---|
469 int ydest; | 469 int ydest; |
470 int width; | 470 int width; |
471 int height; | 471 int height; |
472 int xsrc; | 472 int xsrc; |
473 int ysrc; | 473 int ysrc; |
474 int srcwidth; | |
475 int srcheight; | |
474 } DWBitBlt; | 476 } DWBitBlt; |
475 | 477 |
476 /* Subclass for a test object type */ | 478 /* Subclass for a test object type */ |
477 @interface DWObject : NSObject {} | 479 @interface DWObject : NSObject {} |
478 -(void)uselessThread:(id)sender; | 480 -(void)uselessThread:(id)sender; |
525 else | 527 else |
526 { | 528 { |
527 image = [[NSImage alloc] initWithSize:[rep size]]; | 529 image = [[NSImage alloc] initWithSize:[rep size]]; |
528 [image addRepresentation:rep]; | 530 [image addRepresentation:rep]; |
529 } | 531 } |
530 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height) | 532 if(bltinfo->srcwidth != -1) |
531 operation:NSCompositeSourceOver fraction:1.0]; | 533 { |
534 [image drawInRect:NSMakeRect(bltinfo->xdest, bltinfo->ydest, bltinfo->width, bltinfo->height) | |
535 fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->srcwidth, bltinfo->srcheight) | |
536 operation:NSCompositeSourceOver fraction:1.0]; | |
537 } | |
538 else | |
539 { | |
540 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) | |
541 fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height) | |
542 operation:NSCompositeSourceOver fraction:1.0]; | |
543 } | |
532 [bltsrc release]; | 544 [bltsrc release]; |
533 [image release]; | 545 [image release]; |
534 } | 546 } |
535 if([bltdest isMemberOfClass:[NSBitmapImageRep class]]) | 547 if([bltdest isMemberOfClass:[NSBitmapImageRep class]]) |
536 { | 548 { |
6615 * xsrc: X coordinate of source. | 6627 * xsrc: X coordinate of source. |
6616 * ysrc: Y coordinate of source. | 6628 * ysrc: Y coordinate of source. |
6617 */ | 6629 */ |
6618 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) | 6630 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) |
6619 { | 6631 { |
6632 dw_pixmap_stretch_bitblt(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc, -1, -1); | |
6633 } | |
6634 | |
6635 /* | |
6636 * Copies from one surface to another allowing for stretching. | |
6637 * Parameters: | |
6638 * dest: Destination window handle. | |
6639 * destp: Destination pixmap. (choose only one). | |
6640 * xdest: X coordinate of destination. | |
6641 * ydest: Y coordinate of destination. | |
6642 * width: Width of the target area. | |
6643 * height: Height of the target area. | |
6644 * src: Source window handle. | |
6645 * srcp: Source pixmap. (choose only one). | |
6646 * xsrc: X coordinate of source. | |
6647 * ysrc: Y coordinate of source. | |
6648 * srcwidth: Width of area to copy. | |
6649 * srcheight: Height of area to copy. | |
6650 * Returns: | |
6651 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. | |
6652 */ | |
6653 int API dw_pixmap_stretch_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight) | |
6654 { | |
6620 DWBitBlt *bltinfo = calloc(1, sizeof(DWBitBlt)); | 6655 DWBitBlt *bltinfo = calloc(1, sizeof(DWBitBlt)); |
6621 NSValue* bi = [NSValue valueWithPointer:bltinfo]; | 6656 NSValue* bi = [NSValue valueWithPointer:bltinfo]; |
6622 | 6657 |
6658 /* Sanity checks */ | |
6659 if((!dest && !destp) || (!src && !srcp) || | |
6660 ((srcwidth == -1 || srcheight == -1) && srcwidth != srcheight)) | |
6661 return DW_ERROR_GENERAL; | |
6662 | |
6623 /* Fill in the information */ | 6663 /* Fill in the information */ |
6624 bltinfo->dest = dest; | 6664 bltinfo->dest = dest; |
6625 bltinfo->src = src; | 6665 bltinfo->src = src; |
6626 bltinfo->xdest = xdest; | 6666 bltinfo->xdest = xdest; |
6627 bltinfo->ydest = ydest; | 6667 bltinfo->ydest = ydest; |
6628 bltinfo->width = width; | 6668 bltinfo->width = width; |
6629 bltinfo->height = height; | 6669 bltinfo->height = height; |
6630 bltinfo->xsrc = xsrc; | 6670 bltinfo->xsrc = xsrc; |
6631 bltinfo->ysrc = ysrc; | 6671 bltinfo->ysrc = ysrc; |
6672 bltinfo->srcwidth = srcwidth; | |
6673 bltinfo->srcheight = srcheight; | |
6632 | 6674 |
6633 if(destp) | 6675 if(destp) |
6634 { | 6676 { |
6635 bltinfo->dest = (id)destp->image; | 6677 bltinfo->dest = (id)destp->image; |
6636 } | 6678 } |
6638 { | 6680 { |
6639 id object = bltinfo->src = (id)srcp->image; | 6681 id object = bltinfo->src = (id)srcp->image; |
6640 [object retain]; | 6682 [object retain]; |
6641 } | 6683 } |
6642 [DWObj performSelectorOnMainThread:@selector(doBitBlt:) withObject:bi waitUntilDone:YES]; | 6684 [DWObj performSelectorOnMainThread:@selector(doBitBlt:) withObject:bi waitUntilDone:YES]; |
6685 return DW_ERROR_NONE; | |
6643 } | 6686 } |
6644 | 6687 |
6645 /* | 6688 /* |
6646 * Create a new static text window (widget) to be packed. | 6689 * Create a new static text window (widget) to be packed. |
6647 * Not available under OS/2, eCS | 6690 * Not available under OS/2, eCS |