[SUB] Centering Images

A forum to store posts deemed exceptionally wise and useful
Post Reply
DarkWhoppy
Posts: 386
Joined: Thu Sep 25, 2003 12:43 pm
Contact:

[SUB] Centering Images

Post by DarkWhoppy »

Alittle suggestion for organizing the forum, if you're submitting something. It's a good idea to put "[SUB]" in the title of the thread, and if you're requesting "[REQ]". Another forum I visit does that.... works out well :-)

Anyway, for those who don't know how to center an image. Here's a quick How-to.

Code: Select all

ITexture* BackGround_Tex = _driver->getTexture("IMAGE.jpg");

s32 BGPosX = (_driver->getScreenSize().Width - BackGround_Tex->getSize().Width)/2; //ScreenX - BMP_Width / 2

s32 BGPosY = (_driver->getScreenSize().Height - BackGround_Tex->getSize().Height)/2; //ScreenY - BMP_Height / 2


_driver->draw2DImage(BackGround_Tex,core::position2d<s32>(BGPosX,BGPosY));
Programmer of the Irrlicht Scene Editor:
Homepage - Forum Thread
Version 2 on its way!!
Post Reply