[SOLVED] loading an image?

Okay, so…

imageObject = OnscreenImage(image = 'img/myimg.png', pos = (0, 0, 0))
imageObject.setTransparency(TransparencyAttrib.MAlpha)

Something wrong with this? My image is 512x256 i also tried 512x512 and non-transparent, but in all cases my image is scales to fit the screen

Yeah, that’s the expected behavior. Anything wrong with that?

Why is it scaled ?

It’s not scaled. That is a scale of (1, 1), which means the quad fills the whole screen.

what?

Oh, now I see the images in your previous post. If it’s bothering you that the aspect ratio is not the same, you should apply a scale to the texture to correct it, or I’ve heard that you can pregenerate cards using egg-texture-cards as well (search the forums for that).

Is it always like this cause I dont see the point?

I will. Wonder what that is

It’s just how that works in a 3D engine. A quad is generated with vertices in 0…1 range, and the texture is applied with the texture coordinates 0…1 matching to the quad UV coordinates 0…1.

Notice that in a 3D engine, a texture’s pixel coordinates don’t matter. Texture coordinates are in the 0…1 range, both width and height, regardless of the aspect ratio.

I think irrlicht doesnt scale your images…

Neither does Panda3D. As I said, your image is unscaled.

[size=92](actually, that’s not 100% true, as it’s scaled in the X by 0.75 to compensate for the window’s aspect ratio, so Panda does even do an effort to counter-scale your images.)[/size]

I am confused

Quote of the day : “stop your lazyness, or it will stop you”

search search search
discourse.panda3d.org/viewtopic.php?t=4151

I think irrlicht doesnt unscale images

(I love panda).

You do know that “unscaled” means the absence of any scaling, right? :slight_smile:

Apparently, irrlicht does scale your image in order for it to be a pixel-perfect match on screen.

oh…

How about a feature request?

I guess we could implement some kind of node in the 2d scene graph that automatically rescales to match one pixel, but I think there’s little use for such a feature, as game UI’s usually must be scalable.

On the other hand, it wouldn’t be hard to add that.
drwr, what do you think? We could provide a base.pixel2d (or so) that is reparented to base.a2dTopLeft and has a scale of (1/winwidth, 1/winheight) so that you just need to do image.setScale(imgwidth, imgheight) for it to have a pixel-perfect size.

my image is 512x256 and the screen is 800x600. What values would you give to setScale() ?

You mean to make it pixel-perfect? You’d need to specify parent=render2d in the OnscreenImage, and specify a scale like this:

img.setScale(512 / 800.0, 1, 256 / 600.0)

Yeah, thanks.
Thats resolution dependant huh?

Yeah. When the window is rescaled you’ll need to adjust that.