Re: setWidth deprecated warning
Re: setWidth deprecated warning
- Subject: Re: setWidth deprecated warning
- From: Darrin Cardani <email@hidden>
- Date: Mon, 1 Aug 2011 10:34:14 -0700
Martin,
It's because FxImages are mostly immutable. There's no safe way to change the image data in an FxImage, so we deprecated the setters and updated the initializers to make it more clear. In the past, when a plug-in called -setWidth:, the image's width member variable would be changed, but the data behind it wouldn't. (Because how can we know if you want to scale or crop it when changing the width.) So the object was then in an inconsistent state and any operations on it were inherently unsafe (at least with bitmaps where reading or writing off the edge could clobber other parts of memory).
Also, it allowed the plug-in to do some unsafe things like changing an output image's bitmap pointer behind the app's back. If that happens, the app no longer knows if the bitmap owns the data pointer or not, so it can't safely free it.
So if you want to change the width or height of an image you now have to create a new image. This shouldn't be a performance hit because you have to regenerate the data, anyway. Creating a new FxImage is a pretty fast operation with the new initializers.
Note that I said they're "mostly" immutable. It is fairly safe to change the field value, for example, since it doesn't require changing the image data. It's rare that you'd want to change that value. But you could, theoretically, create a new image that you're using as an intermediate buffer, and set the field value to match something the app passed you, or something like that. Not a common case, but much less problematic than changing the width or height.
Darrin
On Jul 30, 2011, at 1:48 AM, Martin Baker wrote:
> Everytime I call FxImage.width, Xcode throws up a warning that "setWidth is deprecated". Why?
>
> Martin Baker
> www.digital-heaven.co.uk
> www.twitter.com/digitalheaven
> www.videospaceonline.com
> www.finalcutters.com
> ------------------------------------------------------
> Digital Heaven Ltd is registered in England and Wales
> Company registration number: 3628396
> Registered address: 55 Lynwood Drive, Worcester Park, Surrey KT4 7AE
> VAT registration number: GB 736 0989 03
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Pro-apps-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
--
Darrin Cardani
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden