• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Dragging Image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dragging Image


  • Subject: Re: Dragging Image
  • From: Herr Witten <email@hidden>
  • Date: Sun, 1 Feb 2004 13:31:05 -0500

I have gotten it to work, but if you know of a better way, please let
me know.

- (NSImage *)dragImageForRows:(NSArray *)dragRows event:(NSEvent
*)dragEvent dragImageOffset:(NSPointPointer)dragImageOffset
{
NSImage* image = [super dragImageForRows: dragRows event: dragEvent
dragImageOffset: dragImageOffset];

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];

if ([dragRows count] > 1 || [[dragRows objectAtIndex: 0] intValue]
== [self selectedRow])
{
NSBitmapImageRep* bitmap = [NSBitmapImageRep imageRepWithData:
[imageProper TIFFRepresentation]];

unsigned char* bitmapData = [bitmap bitmapData];
int n = [bitmap bitsPerPixel] / 8;
int pixelsWide = [bitmap pixelsWide];
int pixelsHigh = [bitmap pixelsHigh];

for (int y = 0; y < pixelsHigh; y++)
{
for (int x = 0; x < pixelsWide; x++)
{
unsigned char* blue = bitmapData;
unsigned char* green = ++bitmapData;
unsigned char* red = ++bitmapData;

if (*red < 110 && *green < 110 && *blue < 110)
{
*red = 255;
*green = 255;
*blue = 255;
}

bitmapData += 2;
}
}

[imageProper removeRepresentation: [[imageProper
representations] objectAtIndex: 0]];
[imageProper addRepresentation: bitmap];
}

return imageProper;
}

On 31 Jan 2004, at 10:48 PM, Herr Witten wrote:


> How do I invert the text to make it white? Thanks.
_______________________________________________
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.

  • Follow-Ups:
    • Re: Dragging Image
      • From: Herr Witten <email@hidden>
  • Prev by Date: Re: Cocoa/Windows parallel dvlpmt
  • Next by Date: How to set up manual bindings
  • Previous by thread: Re: Sliding views
  • Next by thread: Re: Dragging Image
  • Index(es):
    • Date
    • Thread