# Creating surfaces

**URL:** <https://discourse.libsdl.org/t/creating-surfaces/8921>\
**Category:** SDL Development\
**Created:** [June 24, 2003, 4:57pm UTC](https://discourse.libsdl.org/t/creating-surfaces/8921 "2003-06-24T16:57:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Herbert\_G\_Fischer](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/h/839c29/32.png) [@Herbert\_G\_Fischer](https://discourse.libsdl.org/u/Herbert_G_Fischer)\
**Post date:** [June 24, 2003, 4:57pm UTC](https://discourse.libsdl.org/t/creating-surfaces/8921/1 "2003-06-24T16:57:01Z")

</div>

Hi,

I need to create a surface, with the same format of another, but, with  
different size. I’m having unexpected problems on my code and I think  
that is something related to this.

Is this correct ?? It will create another surface with the same format  
from surface “image” ??

surface = SDL\_CreateRGBSurface(  
image-\>flags, frameSize.w, frameSize.h,   
image-\>format-\>BitsPerPixel,  
image-\>format-\>Rmask, image-\>format-\>Gmask,  
image-\>format-\>Bmask, image-\>format-\>Amask  
);

Thanks!

Herbert

---

<div class="post-metadata">

**Author:** ![Herbert\_G\_Fischer](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/h/839c29/32.png) [@Herbert\_G\_Fischer](https://discourse.libsdl.org/u/Herbert_G_Fischer)\
**Post date:** [June 24, 2003, 5:35pm UTC](https://discourse.libsdl.org/t/creating-surfaces/8921/2 "2003-06-24T17:35:02Z")

</div>

Now I’m shure… It’s really wrong, but I still don’t know the correct  
way to do the same as SDL\_DisplayFormat, but with a different size.

H. G. Fischer wrote:\> Hi,

> I need to create a surface, with the same format of another, but, with  
> different size. I’m having unexpected problems on my code and I think  
> that is something related to this.
> 
> Is this correct ?? It will create another surface with the same format  
> from surface “image” ??
> 
> surface = SDL\_CreateRGBSurface(  
> image-\>flags, frameSize.w, frameSize.h,  
> image-\>format-\>BitsPerPixel,  
> image-\>format-\>Rmask, image-\>format-\>Gmask,  
> image-\>format-\>Bmask, image-\>format-\>Amask  
> );
> 
> Thanks!
> 
> Herbert
> 
> * * *
> 
> SDL mailing list  
> SDL at [libsdl.org](http://libsdl.org)  
> [http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [June 25, 2003, 8:09am UTC](https://discourse.libsdl.org/t/creating-surfaces/8921/3 "2003-06-25T08:09:01Z")

</div>

> Hi,

> I need to create a surface, with the same format of another, but, with  
> different size. I’m having unexpected problems on my code and I think  
> that is something related to this.

> Is this correct ?? It will create another surface with the same format  
> from surface “image” ??

> surface = SDL\_CreateRGBSurface(  
> image-\>flags, frameSize.w, frameSize.h,   
> image-\>format-\>BitsPerPixel,  
> image-\>format-\>Rmask, image-\>format-\>Gmask,  
> image-\>format-\>Bmask, image-\>format-\>Amask  
> );

That looks correct. Make sure that you’re setting the palette, if any.

See ya,  
-Sam Lantinga, Software Engineer, Blizzard Entertainment
