• 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: Not even a portion of a window?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Not even a portion of a window?


  • Subject: Re: Not even a portion of a window?
  • From: Lorenzo <email@hidden>
  • Date: Sat, 16 Jul 2005 12:05:30 +0200

Thanks Joar, but I need to iterate that call for many hundreds times and

    dataWithPDFInsideRect

is very slow.
Indeed I have to trasnform a very long textView in several NSImages and save
them to the disk for storage. I tried to lock the whole textView and call

    [nsImage lockFocus];
    [textView drawRect:[textView bounds]];
    [nsImage unlockFocus];

and it worked very well. But on big views it cannot cache the image.
I have to take the textView content chunk by chunk.
So I created a window with chunkSize (1024 x 500) and I added the subview
textView as it is (1024 x 50,000). Then in a loop I move the textView down
by the kChunkHeight = 500.

for(i = 0; i < totMaps; i++){

    [textView setFrameOrigin:NSMakePoint(0, -i * kChunkHeight)];
    [contentView display];

    [contentView lockFocus];
        rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:imageRect];
        imageData = [rep TIFFRepresentation];
        fileName = [NSString stringWithFormat:@"/Storage/image_%d.tiff", i];
        [imageData writeToFile:fileName  atomically:YES];
    [contentView unlockFocus];

}


But I get strange results. Some image is ok, some image is not.
A guy here told me
> When the drawing focus is locked on an image, the changes you've made
> to the coordinate system of your view aren't applied to the current
> drawing context.
But I indeed lock the focus of the window contentView *after* I changed the
position of the textView. Then I unlock it again.

Last, using cacheDisplayInRect I get a freeze at the first call.
for(i = 0; i < totMaps; i++){
    [textView setFrameOrigin:NSMakePoint(0, -i * kChunkHeight)];
    [contentView display];

    rep = [contentView bitmapImageRepForCachingDisplayInRect:imageRect];
    [contentView cacheDisplayInRect:imageRect toBitmapImageRep:rep];
    // etc.
}

After 3 days I am still at the NSZeroPoint.... :-)


Best Regards
--
Lorenzo
email: email@hidden

> From: j o a r <email@hidden>
> Date: Fri, 15 Jul 2005 19:26:58 +0200
> To: Lorenzo <email@hidden>
> Cc: email@hidden
> Subject: Re: Not even a portion of a window?
>
>
> On 15 jul 2005, at 19.20, Lorenzo wrote:
>
>> why can't I get an image of my window?
>> I get an empty image all the time. What did I miss?
>
> <snip>
>
>>         [[aWindow contentView] drawRect:imageRect];
>
> Do you have a custom content view subclass that draws something
> interesting? If not, I would assume that it doesn't draw anything per
> default, and that would be why your image ends up being empty.
>
> Perhaps you'd rather look at this method:
>
>    -[NSWindow dataWithPDFInsideRect:]
>
>>         imageData = [image TIFFRepresentation];
>
> I think that you should move this out of the focus-locked area.
>
> j o a r
>
>
>
>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Not even a portion of a window? (From: j o a r <email@hidden>)

  • Prev by Date: Re: Preventing flicker on moving NSView to a different superview
  • Next by Date: having trouble setting the current cursor
  • Previous by thread: Re: Not even a portion of a window?
  • Next by thread: Re: Not even a portion of a window?
  • Index(es):
    • Date
    • Thread