David hello.
I didn't use blocks, in order to support 3.2, just in case, you never know who
is out there still using it. so I sue normal [NSObject performSelectorOnThread
methods,..
Now I divided the Saving operation and the thumbnail creation in 2 separate
threads, the thumbnail is inside the thread of saving, now its much faster,
encoding and saving takes little time, I believe that the thumbnail creation is
the responsible for slowing the process.
Basically and I think Im very wrong in whatIm doing is create a screenshot of
the View with all its subviews, following Apple docs to do so, so each view's
layer renderInContext is called. Of course I previously create a
UIImageCOntext, then after I get that image, I scaled it down
to the thumb dimensions, but here is where it get's messy:
The thumb must have a rounded corner mask + the border stroke, if I do that in
the same UIImageContext I created to resize the screenShot I got, then I get no
rounded corners for the image but the stroke of the path is rounded. So I was
reading a little and to add a clip to a context I must have a BItMapContext, in
this case the image gets rounded corners but if I try to stroke the path the
clip I add goes away.
So what I did was, create the thumb with a UIImageContext, then clip it using a
UIBitMapContext, then create a final Image using once again a UIImageContext
which in this case I draw the rounded corner image and then stroke the path.
So I believe I can do better in this process.
Thx
Gustavo
On Dec 7, 2010, at 1:59 PM, David Reed wrote:
>
> On Dec 7, 2010, at 3:16 AM, Gustavo Pizano wrote:
>
>> Hello Guys..
>>
>> I see, I have been using GCD and blocks but on somme OSX app I did before,
>> not on iPhone, I tough tit wasn't there... :P.
>
>
> Blocks/GCD are in iOS 4.0 and higher. Assuming you have a paid developer
> account, you may want to watch the relevant WWDC videos from last year.
>
>>
>> SO, I from within the method( block) that makes all the saving process, I do
>> something like
>>
>>>> dispatch_async(dispatch_get_main_queue(), ^{
>>>> // code executed on main thread goes here (i.e., updating the
>>>> progress indicator in your case
>>>>
>>>> });
>>
>>
>> and update the progress indicator bar, great im gonna try that..
>
>
> Yes.
>
>
>>
>> also I have the option to call from within the same method a
>> [<MyConotroller With the Progress indicator> performSelectorinMainThread:
>> withObject:<NSNumber with the float value to add> waitUntilDone:NO];
>>
>> right?
>
>
> Yes, ssuming the selector you pass (you left it out) takes the NSNumber and
> updates the progress bar.
>
>
>>
>>
>> What about the saving operation improving its saving time?, I will check
>> today what takes longer, if creating the thumbnial, or encoding the views,
>> maybe I shouldn't encode the whole view, but s just the image reference and
>> the transform matrix... ?/ I will try that one also.
>
>
> I didn't look at your code closely and don't have the other code around it to
> profile which part is taking so long.
>
> Dave
>
>
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]