wrong image size ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

wrong image size ?

Antônio Gomes-2
hi,

a simple question: what is the best way to get the size of images ? I am
trying with both nsDOMHTMLImageElement->GetLenght/Width and
imgIContainer->GetLenght|Width and sometimes they get me wrong value
(comparing to the ones firefox gets me - page info) ..

regards


_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout
Reply | Threaded
Open this post in threaded view
|

Re: wrong image size ?

Antônio Gomes-2
ext Antônio Gomes wrote:

> hi,
>
> a simple question: what is the best way to get the size of images ? I
> am trying with both nsDOMHTMLImageElement->GetLenght/Width and
> imgIContainer->GetLenght|Width and sometimes they get me wrong value
> (comparing to the ones firefox gets me - page info) ..
>
> regards
>
Humm, it seems like the image size is not the same as the size of its
container. e.g.

                (...)

            imgList->Item(i, getter_AddRefs(node));
            nsCOMPtr<nsIDOMHTMLImageElement> img;
            img = do_QueryInterface(node);

            /// testing imgl* interfaces (from imglib2 - modules/libpr0n/) out instead of nsIDOMHTMLImage->GetHeight|Width/
            nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(img);
            *if* (imageLoader) {
                nsCOMPtr<imgIRequest> imgRequest;
                rv = imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST, getter_AddRefs(imgRequest));
 
                *if* (imgRequest) {
   
                    nsCOMPtr<imgIContainer> imgContainer;
                    rv = imgRequest->GetImage(getter_AddRefs(imgContainer));
   
                    *if* (imgContainer) {
                        rv = imgContainer->GetHeight( &heigth);
                        rv = imgContainer->GetWidth( &width);

                            }
                      }
                }
                (...)

So, before start loading the image, its container (imgContainer) size
might be different from the real image size ? Is it ? Does mozilla
supposes its (container) initial size ?

regards
_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout
Reply | Threaded
Open this post in threaded view
|

Re: wrong image size ?

Neil Deakin
In reply to this post by Antônio Gomes-2
Antônio Gomes wrote:
> hi,
>
> a simple question: what is the best way to get the size of images ? I am
> trying with both nsDOMHTMLImageElement->GetLenght/Width and
> imgIContainer->GetLenght|Width and sometimes they get me wrong value
> (comparing to the ones firefox gets me - page info) ..
>

Are you trying to get the real size of the image, or the displayed size?

The real size is retrievable using the naturalWidth and naturalHeight
properties of nsDOMNSHTMLImageElement.

/ Neil
_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout