• 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: Switching off antialiasing...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Switching off antialiasing...


  • Subject: Re: Switching off antialiasing...
  • From: Marcel Weiher <email@hidden>
  • Date: Thu, 19 Jul 2001 11:22:06 +0200

On Thursday, July 19, 2001, at 10:30 Uhr, Stefan Jung wrote:

...is very easy for the on screen display. But what is the trick to
do this with an image?

Just the same...

I tried a lot with lockig focus and so on...no chance. The TIFF I
want to save is always antialiased, regardless it is set or not.

That's because the conversion to TIFF is not happening where you think it's happening.

My code:

-(void)saveAsTIFF:sender
{
NSImage *specImage;
NSSavePanel *sp;
int result;
NSGraphicsContext *graphicsContext;

specImage = [[NSImage alloc] initWithSize:[self bounds].size];
[specImage lockFocus];
graphicsContext = [NSGraphicsContext currentContext];
[graphicsContext setShouldAntialias:NO];
[specImage initWithData:[self dataWithPDFInsideRect:[self bounds]]];

This initializes the specImage with the PDF-representation of your view. It doesn't actually render anything. It is also wrong in that you're sending an -init... message to an NSImage that's already been initialized.

Try [self drawRect:[self bounds]] instead (not 100% sure, but it's the right direction, somehow I think [self frame] would be better)

[specImage unlockFocus];

sp = [NSSavePanel savePanel];
[sp setRequiredFileType:@"TIFF"];

result = [sp runModalForDirectory:NSHomeDirectory() file:[[self
window] title]];

if (result == NSOKButton) {
if (![[specImage TIFFRepresentation] writeToFile:[sp
filename] atomically:YES])

This is where the rendering is taking place in your example, and since the current-context has changed again, you're not seeing the effects of setAntiAlias of the previous context.

Marcel


  • Follow-Ups:
    • Re: Switching off antialiasing...
      • From: Stefan Jung <email@hidden>
References: 
 >Switching off antialiasing... (From: Stefan Jung <email@hidden>)

  • Prev by Date: Switching off antialiasing...
  • Next by Date: Re: Switching off antialiasing...
  • Previous by thread: Switching off antialiasing...
  • Next by thread: Re: Switching off antialiasing...
  • Index(es):
    • Date
    • Thread