SDL_Surface->w and ->h fields not getting bitmap width and height in v1.2.8

Hello,
I have a question regarding getting the width and height of a bitmap that
has been loaded onto an SDL_Surface using IMG_Load in version 1.2.8. Are the
width and height of the bitmap stored in the Rect’s ->w and ->h variables? I
have tried inspecting surfaces onto which bitmaps have been loaded, and the
Rect’s w and h values are returned as zero (this bug is also mentioned as a
comment in the description of the SDL_Rect structure in the SDL doc wiki).
Has this issue been addressed in version 1.2.9, or is there a way to get the
width and height of a bitmap of which I am not aware? Any help would be
greatly appreciated. Thanks in advance.

Chris Dickinson

Chris Dickinson wrote:

Hello,
I have a question regarding getting the width and height of a bitmap that
has been loaded onto an SDL_Surface using IMG_Load in version 1.2.8. Are the
width and height of the bitmap stored in the Rect’s ->w and ->h variables? I
have tried inspecting surfaces onto which bitmaps have been loaded, and the
Rect’s w and h values are returned as zero (this bug is also mentioned as a
comment in the description of the SDL_Rect structure in the SDL doc wiki).

I’m not sure what “Rect” you are talking about, but when I do

surf = IMG_Load_RW(rw, 1);

then surf->w and surf->h do contain the image’s dimensions afterwards,
and I suppose it’s the same with IMG_Load(). This is with SDL 1.2.8 and
SDL_image 1.2.4 on Mac OS X, Linux, and Windows.

That comment on the SDL_Surface wiki page doesn’t make much sense to me

  • SDL_Surface doesn’t even have x and y fields.

Can you show us a complete test program that exhibits the behavior you
describe?

-Christian

Christian Walther <cwalther gmx.ch> writes:

Chris Dickinson wrote:

Hello,
I have a question regarding getting the width and height of a bitmap
that

has been loaded onto an SDL_Surface using IMG_Load in version 1.2.8. Are
the

width and height of the bitmap stored in the Rect’s ->w and ->h
variables? I

have tried inspecting surfaces onto which bitmaps have been loaded, and
the

Rect’s w and h values are returned as zero (this bug is also mentioned as
a

comment in the description of the SDL_Rect structure in the SDL doc
wiki).

I’m not sure what “Rect” you are talking about, but when I do

surf = IMG_Load_RW(rw, 1);

then surf->w and surf->h do contain the image’s dimensions afterwards,
and I suppose it’s the same with IMG_Load(). This is with SDL 1.2.8 and
SDL_image 1.2.4 on Mac OS X, Linux, and Windows.

That comment on the SDL_Surface wiki page doesn’t make much sense to me

  • SDL_Surface doesn’t even have x and y fields.

Can you show us a complete test program that exhibits the behavior you
describe?

-Christian

I apologize for referring to the SDL_Surface structure as an SDL_Rect - I was
referring to the width and height fields of an SDL_Surface throughout my
posting. I do know that when I load a bitmap using IMG_Load, the values in
the resulting surface’s width and height fields are equal to zero (unless I am
not accessing them correctly). I will try using IMG_Load_RW and see if this
still is a problem. Thanks for the idea.

Chris Dickinson

if you are loading a bitmap - a MS .BMP, try using

SDL_Surface *surface = SDL_LoadBMP( “random.bmp” );

to see if that works…

the only reason the w and h fields would be zero would be the bitmap was
empty for some reason…

Brian Barrett <brian.ripoff gmail.com> writes:

if you are loading a bitmap - a MS .BMP, try using
SDL_Surface *surface = SDL_LoadBMP( “random.bmp” );
to see if that works…
the only reason the w and h fields would be zero would be the bitmap was
empty for some reason…


SDL mailing list
SDL libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Thanks for the replies - I tried loading a few images of different sizes and
sending the width and height of the respective surfaces to a text file - it
turns out that all of the bitmaps are being loaded as full-screen images.
Thanks again.

Chris Dickinson