Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 85437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:05:21+00:00 2026-05-10T22:05:21+00:00

As I stated in this question , I am using SDL for a small

  • 0

As I stated in this question, I am using SDL for a small game I’m developing. Now I am having problems with SDL_DisplayFormatAlpha. I am trying to create a surface with an alpha channel from a PNG image. It was working before, but now that I’ve done some slight refactoring something got broken. I’ve narrowed it down to this constructor:

 Surface::Surface( tfilename file ) {     // initialize the surface data member to the image indicated by filename     SDL_Surface *tempSurface;     tempSurface = IMG_Load( file.c_str() );     if ( !tempSurface ) {         surface = NULL;         exit(1);     }     else {         surface = SDL_DisplayFormatAlpha( tempSurface );         //surface = tempSurface;     }     SDL_FreeSurface( tempSurface ); } 

This compiles just fine, but when I run it I get a Segmentation fault. The error reported by gdb:

 Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb79c16c0 (LWP 8089)] 0xb7e8b9a3 in SDL_DisplayFormatAlpha () from /usr/lib/libSDL-1.2.so.0 

The stack trace is as follows:

 #0  0xb7e8b9a3 in SDL_DisplayFormatAlpha () from /usr/lib/libSDL-1.2.so.0 #1  0x0804987e in Surface (this=0x804d060, file=@0xbfb20760) at Surface.cpp:16 #2  0x0804a159 in Image (this=0x804d038, x=0, y=0, file=@0xbfb207a0)     at Image.cpp:16 #3  0x0804a3de in Object (this=0x804d028, imageFile=@0xbfb207dc)     at Object.cpp:4 #4  0x080491cb in Application (this=0xbfb20810) at Application.cpp:8 #5  0x08048e0d in main () at main.cpp:5 

If I comment out surface = SDL_DisplayFormatAlpha( tempSurface ); and SDL_FreeSurface( tempSurface ); and uncomment surface = tempSurface; like so:

  Surface::Surface( tfilename file ) {     // initialize the surface data member to the image indicated by filename     SDL_Surface *tempSurface;     tempSurface = IMG_Load( file.c_str() );     if ( !tempSurface ) {         surface = NULL;         exit(1);     }     else {         //surface = SDL_DisplayFormatAlpha( tempSurface );         surface = tempSurface;     }     //SDL_FreeSurface( tempSurface ); }

Then it seems to work just fine. Can anyone tell me what’s going on? Actually, the transparency seems to work, too when I comment out SDL_DisplayFormatAlpha. Is that function only meant to be used with images that do not already have an alpha channel?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:05:22+00:00Added an answer on May 10, 2026 at 10:05 pm

    IMG_Load should handle transparent PNG’s automatically, as the end of your post notes. What is the actual exception/error being thrown? Your stack trace doesn’t show that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 64k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer This sounds like the right way to do it, although… May 11, 2026 at 10:47 am
  • added an answer This seems to do the trick, and saves the 'set'… May 11, 2026 at 10:47 am
  • added an answer Let's not mix ethics here. Bad ethics would be stealing… May 11, 2026 at 10:47 am

Related Questions

As I stated in this question , I am using SDL for a small
As stated in the title, i'm looking for an XML schema (XSD-file) for the
As stated in the title, I need double shortcut keys for my application (ie.
When I first started programming, I wrote everything in main. But as I learned,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I've started using bazaar DVCS for a project in a single-user mode, as described
I need to access the OpenGL state variables (such as the MVP matrices) in
As the question states, i am a C#/Java programmer who is interested in (re)learning
I started with a query: SELECT strip.name as strip, character.name as character from strips,
Recently, I started changing some of our applications to support MS SQL Server as

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.