x


Getting height and width of images

I need to load images with different sizes. Is there any way to get the height and width of an uploaded file with LoadImageIntoTexture?

more ▼

asked May 02 '11 at 01:29 AM

user-12274 (google) gravatar image

user-12274 (google)
1 1 1 1

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

LoadImageIntoTexture takes a provided Texture2D and assigns the loaded image to it. From that you can use that Texture2D and use its width and height properties to get that info.

Texture2D class ref

Texture class ref

Cheers

==

more ▼

answered May 02 '11 at 01:39 AM

equalsequals gravatar image

equalsequals
4.5k 16 28 64

Thanks for the reply. This is how I use now, but I have to inform in advance the width and height of each image. The ideal would have a method to identify the dimensions from the file, automatically, allowing me to exchange files with others of different sizes. Any suggestions?

May 03 '11 at 01:52 AM user-12274 (google)

What method are you using to load these textures in?

May 04 '11 at 01:27 PM equalsequals

Im using LoadImageIntoTexture and applying on a Cube. I need to know the size of image to set Cube's scale.

May 05 '11 at 02:28 AM user-12274 (google)

I see the LoadImageIntoTexture, so these image files exist on a web server? Why don't you just reflect their dimensions in a file name (ie MyImage_100x100.png)?

May 05 '11 at 01:33 PM equalsequals
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x258
x94
x35
x9

asked: May 02 '11 at 01:29 AM

Seen: 1671 times

Last Updated: May 02 '11 at 01:29 AM