Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Rendering image from javascript to obj-c
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rendering image from javascript to obj-c




On Aug 3, 2011, at 8:11 AM, Andrew Davis wrote:

To be very clear on what I am looking for, i have given the pseudo below.


So, on the html side, i have something like this...
function getImage(url)
{
  var image=new Image();
  image.src="">
  image.>
}
function onLoad(image)
{
  returns the image data to Obj-C method
}

On the Obj-C side, i get the result as a WebScriptObject which inturn is a DOMHTMLImageElement object. So, i get the result as this object.
- (void) setImage:(DOMHTMLImageElement *)imageData
{
  [imageData src] -> works fine (gives me the url that has been passed to the getImage in JS)
  [imageData height] --> gives the correct height of the image
  [imageData width] --> gives the correct width of the image
  [imageData image] --> always nil.. (It is supposed to give me the image as a NSImage* and i was to use this for populating my ImageView)

The -image method only works when the element is participating in rendering the document. In particular, if the element is not in the DOM tree or is styled with display: none or has an ancestor with display: none, then -image will return nil.

}

So, this is exactly what I am doing and I need that image data for my use within Obj-C. Please let me know what i can do to get this done.
Note: I have this problem only when i try to get the image data. Strings work fine.

Thanks.


On Mon, Aug 1, 2011 at 5:14 PM, Andrew Davis <email@hidden> wrote:

I actually want the data as a NSImage object coz I am trying to load a image view with that data.
All the other API's of DOMHTMLImageElement work fine and give me the proper result. Only the image api doesn't work as expected. I am not sure what I am missing. I tried a sample html file and loaded the images on the page using the same js. They loaded fine. Only when I send it across to cocoa, image api returns nil all the time.

On Aug 1, 2011 5:07 PM, "Mike Abdullah" <email@hidden> wrote:
>
> On 1 Aug 2011, at 12:23, Andrew Davis wrote:
>
>> If you meant NSURLConnection, I can do so. But I am trying it this way. I m trying to get as much data from the js. Thanks for giving me the other options. But, I m so focussed in getting it this way.
>>
>
> Well seeing as you ask for the "image data", I'm trying to narrow down what you'd ideally like. An NSImage, or a lump of NSData? Perhaps something else? If you do get the -image API to work, and want raw data, you'll have to convert to JPEG/PNG yourself which probably isn't ideal.
>
> Also, NSURLConnection somewhat of a last resort. You should be able to consult the web view's resources first, as well as the URL cache.
>

Do not post admin requests to the list. They will be ignored. Webkitsdk-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Rendering image from javascript to obj-c (From: Andrew Davis <email@hidden>)
 >Re: Rendering image from javascript to obj-c (From: Mike Abdullah <email@hidden>)
 >Re: Rendering image from javascript to obj-c (From: Andrew Davis <email@hidden>)
 >Re: Rendering image from javascript to obj-c (From: Mike Abdullah <email@hidden>)
 >Re: Rendering image from javascript to obj-c (From: Andrew Davis <email@hidden>)
 >Re: Rendering image from javascript to obj-c (From: Andrew Davis <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.