Re: Dragging Image
Re: Dragging Image
- Subject: Re: Dragging Image
- From: Herr Witten <email@hidden>
- Date: Sun, 1 Feb 2004 14:37:09 -0500
Here is a better way:
- (NSImage *)dragImageForRows:(NSArray *)dragRows event:(NSEvent
*)dragEvent dragImageOffset:(NSPointPointer)dragImageOffset
{
NSImage* image = [super dragImageForRows: dragRows event: dragEvent
dragImageOffset: dragImageOffset];
if ([dragRows count] > 1 || [[dragRows objectAtIndex: 0] intValue]
== [self selectedRow])
{
NSBitmapImageRep* bitmap = [NSBitmapImageRep imageRepWithData:
[image TIFFRepresentation]];
unsigned char* bitmapData = [bitmap bitmapData];
int pixelsWide = [bitmap pixelsWide];
int pixelsHigh = [bitmap pixelsHigh];
for (int y = 0; y < pixelsHigh; y++)
{
for (int x = 0; x < pixelsWide; x++)
{
unsigned char* alpha = (bitmapData += 4) - 1;
if (*alpha > 10)
{
*alpha = 255;
*(alpha - 1) = 255;
*(alpha - 2) = 255;
*(alpha - 3) = 255;
}
}
}
[image removeRepresentation: [[image representations]
objectAtIndex: 0]];
[image addRepresentation: bitmap];
}
NSImage* imageProper = [[NSImage alloc] initWithSize: [image size]];
[imageProper lockFocus];
[[[NSColor selectedControlColor] colorWithAlphaComponent: 0.5]
set];
NSRect fillRect = NSMakeRect(0, 0, 0, 0);
fillRect.size = [imageProper size];
[NSBezierPath fillRect: fillRect];
[image dissolveToPoint: NSMakePoint(0, 0) fraction: 1.0];
[imageProper unlockFocus];
return imageProper;
}
On 1 Feb 2004, at 1:31 PM, Herr Witten wrote:
>
I have gotten it to work, but if you know of a better way, please let
>
me know.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.