<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Wii SDL not showing ,png images?</title>
<description> Okay so the program compiles, and runs like normal except that it doesn&amp;#039;t display the PNG image. I tried it as a BMP and it worked by loading it like so:

player=SDL_LoadBMP(&quot;sd:/pngmove/data/graphics/player.bmp&quot;);

But loading a PNG like this

rwop=SDL_RWFromFile(&quot;sd:/pngmove/data/graphics/player.png&quot;, &quot;rb&quot;);

player=IMG_Load(rwop);

doesn&amp;#039;t give me a compileing error, and the program runs fine, but the PNG doesn&amp;#039;t show up.

so I tried loading it like this

player=IMG_Load(&quot;sd:/pngmove/data/graphics/player.png&quot;);

and it still didn&amp;#039;t work. I&amp;#039;m not getting any errors though, SDL must be compiled to use pngs.

Why isn&amp;#039;t my png showing up? and how can I load a PNG in a way that it will show up?

Here is the full code:

// normal includes
#include 
#include 
#include 
#include 
#include 

// SDL includes
#include 
#include 

// screen surface, the place where everything will get print onto
SDL_Surface *screen = NULL;
SDL_Surface *player = NULL;

int playerX = 50;
int playerY = 50;

SDL_RWops *rwop;

void init(){

// initialize SDL video. If there was an error SDL shows it on the screen
if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO) &amp;lt; 0 )
{
fprintf(stderr, &quot;Unable to init SDL: %s\n&quot;, SDL_GetError() );
SDL_Delay( 5000 );
exit(EXIT_FAILURE);
}

// button initialization
WPAD_Init();

// make sure SDL cleans up before exit
atexit(SDL_Quit);
SDL_ShowCursor(SDL_DISABLE);

// create a new window
screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF);
if ( !screen )
{
fprintf(stderr, &quot;Unable to set video: %s\n&quot;, SDL_GetError());
SDL_Delay( 5000 );
exit(EXIT_FAILURE);
}
}

// this will be used in further lessons, not in lesson 1
void apply_surface ( int x, int y, SDL_Surface* source, SDL_Surface* destination ){

// make a temporary rectangle to hold the offsets
SDL_Rect offset;

// give the offsets to the rectangle
offset.x = x;
offset.y = y;

// blit the surface
SDL_BlitSurface( source, NULL, destination, &amp;offset );
}

void cleanup(){

// we have to quit SDL
SDL_Quit();
exit(EXIT_SUCCESS);
}

int main(int argc, char** argv){
// main function. Always starts first

// to stop the while loop
bool done = false;

// start init() function
init();

fatInitDefault();

player=SDL_LoadBMP(&quot;sd:/pngmove/data/graphics/player.bmp&quot;);

if(player == NULL)
printf(&quot;error!&quot;);

// this is the endless while loop until done = true
while (!done)
{
// scans if a button was pressed
WPAD_ScanPads();
u32 held = WPAD_ButtonsHeld(0);

SDL_FillRect(screen, 0, SDL_MapRGB(screen-&amp;gt;format, 0, 33, 33));
apply_surface(playerX, playerY, player, screen);

if(held){
if(WPAD_BUTTON_HOME){
done=true;
SDL_FillRect(screen, 0, SDL_MapRGB(screen-&amp;gt;format, 0, 0, 0));
}

if(WPAD_BUTTON_UP){
playerY-=2;
}

if(WPAD_BUTTON_DOWN){
playerY+=2;
}

if(WPAD_BUTTON_LEFT){
playerX-=2;
}

if(WPAD_BUTTON_RIGHT){
playerX+=2;
}
}



// SDL_Flip refreshes the screen so it will show the updated screen
SDL_Flip(screen);
}

// start cleanup() function
cleanup();

return 0;
}</description><link>http://forum.wiibrew.org/read.php?11,57397,57397#msg-57397</link><lastBuildDate>Sun, 13 Sep 2026 12:58:11 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,57397,57798#msg-57798</guid>
<title>Re: Wii SDL not showing ,png images?</title><link>http://forum.wiibrew.org/read.php?11,57397,57798#msg-57798</link><description><![CDATA[ Okay, it finally worked! ^_^<br /><br />I guess I had to install the latest SVN for Wii SDL and not the .zip one. Thank you for all your help scanff, and everyone else! ^_^]]></description>
<dc:creator>Cypri</dc:creator>
<category>Coding</category><pubDate>Mon, 16 Aug 2010 00:18:23 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,57397,57749#msg-57749</guid>
<title>Re: Wii SDL not showing ,png images?</title><link>http://forum.wiibrew.org/read.php?11,57397,57749#msg-57749</link><description><![CDATA[ The only other thing I can think of is download another HB project that loads pngs and build it to see if they load on it.<br /><br />My projects wiiradio and bash the castle both use SDL and load png&#039;s from the SD card.]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Sun, 15 Aug 2010 01:38:50 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,57397,57564#msg-57564</guid>
<title>Re: Wii SDL not showing ,png images?</title><link>http://forum.wiibrew.org/read.php?11,57397,57564#msg-57564</link><description><![CDATA[ Okay, thank you. I tried that and it still didn&#039;t work. :(/<br />I first put the lib and include folders straight into the respective folders (inside the libogc folder), and tried it and it didn&#039;t work. Than I went in and deleted the lib png files (and found out I was suppose to put then in lib\wii and not just lib) and tried to compile it, and it sai libpng wasn&#039;t found (to test if I got all the lib png out) than I reinstalled the libpng files again (with the lib folders contents in lib/wii) and tried it and it still didn&#039;t work. I get the same "can not allocate memory for png, or using incompatable png dll." error. The only thing I can think of is installing the newest zlib (which I think I already have) but my hopes are very low...<br /><br />Edit: reinstalling zlib didn&#039;t work either...<br /><br />edit2: creating a PNG in GIMP didn&#039;t work at all]]></description>
<dc:creator>Cypri</dc:creator>
<category>Coding</category><pubDate>Fri, 13 Aug 2010 10:03:53 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,57397,57560#msg-57560</guid>
<title>Re: Wii SDL not showing ,png images?</title><link>http://forum.wiibrew.org/read.php?11,57397,57560#msg-57560</link><description><![CDATA[ Here&#039;s the current portlib png [<a href="http://sourceforge.net/projects/devkitpro/files/portlibs/libpng-1.4.1-ppc.tar.bz2/download" rel="nofollow">sourceforge.net</a>]<br /><br />Yes you should not need to compile, just copy to the include and lib folders under libogc.]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Fri, 13 Aug 2010 08:14:28 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,57397,57521#msg-57521</guid>
<title>Re: Wii SDL not showing ,png images?</title><link>http://forum.wiibrew.org/read.php?11,57397,57521#msg-57521</link><description><![CDATA[ I&#039;m using Photoshop. I figured out with some logging that SDL_errorGet (getError?) is returning "can not allocate memory for png, or using incompatable png dll." Now the .png is only 32x32 so I know it&#039;s not the allocated memory thing. I&#039;m trying to reinstall libpng from the portlibs section of devkitpro&#039;s site, but I am running into oddities and errors. First off I have no DRIVE:\devkitPro\portlibs folder, but I have libpng installed because I&#039;m not getting linker errors. Second is I heard that the libs in devkitPro&#039;s site were precompiled, but the one I found of libpng (for PPC) had make and install files, and no include and lib folders. Third is that the make file for libpng has a lot of errors in it, so I can&#039;t make it.<br /><br />I can&#039;t reinstall devkitPro because my PC doesn&#039;t have internet access anymore.<br /><br />So can anyone help me?]]></description>
<dc:creator>Cypri</dc:creator>
<category>Coding</category><pubDate>Thu, 12 Aug 2010 21:38:23 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,57397,57449#msg-57449</guid>
<title>Re: Wii SDL not showing ,png images?</title><link>http://forum.wiibrew.org/read.php?11,57397,57449#msg-57449</link><description><![CDATA[ What program are you using to create the png?<br /><br />I had issues with an older version of paint shop pro creating png&#039;s but after running them through gimp everything worked.<br /><br />Also the png IMG_Load is part of SDL image which is different from loading a bitmap, the SDL_LoadBMP is in the main SDL library. If libpng is not installed I&#039;d expect link errors but who knows.]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Wed, 11 Aug 2010 22:41:38 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,57397,57430#msg-57430</guid>
<title>Re: Wii SDL not showing ,png images?</title><link>http://forum.wiibrew.org/read.php?11,57397,57430#msg-57430</link><description><![CDATA[ Thank you all for your replies. Using the method of testing suggested by scanff I have figured out that my player image is null. I have looked in the sd cards path and confirmed that the image is there, and loaded a .bmp from the same path, so that is not the problem.<br /><br />Also I would like to point out that the bliting I use in my program worked perfectly fine for the .bmp, so I don&#039;t think it&#039;s a blit problem.]]></description>
<dc:creator>Cypri</dc:creator>
<category>Coding</category><pubDate>Wed, 11 Aug 2010 19:01:36 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,57397,57428#msg-57428</guid>
<title>Re: Wii SDL not showing ,png images?</title><link>http://forum.wiibrew.org/read.php?11,57397,57428#msg-57428</link><description><![CDATA[ Are you sure that image.png is where you think it is? try sd:/image.png if it&#039;s on the sd card.<br /><br />You can test like so:<br /><br />SDL_Surface *image = 0;<br />image = IMG_Load("image.png");<br />if(!image) exit(0);<br /><br />Also what happens if you do this :-<br /><br />offset.x = 1;<br />offset.y = 1;<br />offset.w = image-&gt;w;<br />offset.h = image-&gt;h;]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Wed, 11 Aug 2010 18:44:45 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,57397,57421#msg-57421</guid>
<title>Re: Wii SDL not showing ,png images?</title><link>http://forum.wiibrew.org/read.php?11,57397,57421#msg-57421</link><description><![CDATA[ im using sdl and i blit png with<br /><br />SDL_Rect offset;<br />SDL_Surface *image;<br />SDL_Surface *screen;<br />image = IMG_Load("image.png");<br />offset.x = 1;<br />offset.y = 1;<br />SDL_BlitSurface(image, NULL, screen, &offset );<br />SDL_Flip(screen);<br />SDL_FreeSurface(image);]]></description>
<dc:creator>the_marioga</dc:creator>
<category>Coding</category><pubDate>Wed, 11 Aug 2010 11:27:15 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,57397,57420#msg-57420</guid>
<title>Re: Wii SDL not showing ,png images?</title><link>http://forum.wiibrew.org/read.php?11,57397,57420#msg-57420</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>Arikado</strong><br />Make sure the width and height of your png image is a multiple of 4.</div></blockquote><br />For SDL that doesn&#039;t matter. We&#039;re not talking about PNGU here.]]></description>
<dc:creator>Tantric</dc:creator>
<category>Coding</category><pubDate>Wed, 11 Aug 2010 07:48:27 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,57397,57406#msg-57406</guid>
<title>Re: Wii SDL not showing ,png images?</title><link>http://forum.wiibrew.org/read.php?11,57397,57406#msg-57406</link><description><![CDATA[ Make sure the width and height of your png image is a multiple of 4.]]></description>
<dc:creator>Arikado</dc:creator>
<category>Coding</category><pubDate>Wed, 11 Aug 2010 05:15:28 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,57397,57397#msg-57397</guid>
<title>Wii SDL not showing ,png images?</title><link>http://forum.wiibrew.org/read.php?11,57397,57397#msg-57397</link><description><![CDATA[ Okay so the program compiles, and runs like normal except that it doesn&#039;t display the PNG image. I tried it as a BMP and it worked by loading it like so:<br /><br /><pre class="bbcode">player=SDL_LoadBMP("sd:/pngmove/data/graphics/player.bmp");</pre><br />But loading a PNG like this<br /><br /><pre class="bbcode">rwop=SDL_RWFromFile("sd:/pngmove/data/graphics/player.png", "rb");
	
player=IMG_Load(rwop);</pre><br />doesn&#039;t give me a compileing error, and the program runs fine, but the PNG doesn&#039;t show up.<br /><br />so I tried loading it like this<br /><br /><pre class="bbcode">player=IMG_Load("sd:/pngmove/data/graphics/player.png");</pre><br />and it still didn&#039;t work. I&#039;m not getting any errors though, SDL must be compiled to use pngs.<br /><br />Why isn&#039;t my png showing up? and how can I load a PNG in a way that it will show up?<br /><br />Here is the full code:<br /><br /><pre class="bbcode">// normal includes
#include <stdlib.h>
#include <time.h>
#include <gccore.h>
#include <wiiuse/wpad.h> 
#include <fat.h>
 
// SDL includes
#include <SDL/sdl.h>
#include <SDL/sdl_image.h>
 
// screen surface, the place where everything will get print onto
SDL_Surface *screen = NULL;
SDL_Surface *player = NULL;

int playerX = 50;
int playerY = 50;

SDL_RWops *rwop;
 
void init(){
 
    // initialize SDL video. If there was an error SDL shows it on the screen
    if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO) &lt; 0 )
    {
        fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError() );
		SDL_Delay( 5000 );
        exit(EXIT_FAILURE);
    }
 
    // button initialization
    WPAD_Init();
 
    // make sure SDL cleans up before exit
    atexit(SDL_Quit);
    SDL_ShowCursor(SDL_DISABLE);
 
    // create a new window
    screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF);
    if ( !screen )
    {
        fprintf(stderr, "Unable to set video: %s\n", SDL_GetError());
		SDL_Delay( 5000 );
        exit(EXIT_FAILURE);
    }
}
 
// this will be used in further lessons, not in lesson 1
void apply_surface ( int x, int y, SDL_Surface* source, SDL_Surface* destination ){
 
     // make a temporary rectangle to hold the offsets
     SDL_Rect offset;
 
     // give the offsets to the rectangle
     offset.x = x;
     offset.y = y;
 
     // blit the surface
     SDL_BlitSurface( source, NULL, destination, &offset );
}
 
void cleanup(){
 
     // we have to quit SDL
     SDL_Quit();
     exit(EXIT_SUCCESS);
}
 
int main(int argc, char** argv){
	// main function. Always starts first
 
	// to stop the while loop
	bool done = false;
 
	// start init() function
	init();
	
	fatInitDefault();

	player=SDL_LoadBMP("sd:/pngmove/data/graphics/player.bmp");
	
	if(player == NULL)
		printf("error!");
 
	// this is the endless while loop until done = true
	while (!done)
        {
		// scans if a button was pressed
        WPAD_ScanPads();
		u32 held = WPAD_ButtonsHeld(0);
 
		SDL_FillRect(screen, 0, SDL_MapRGB(screen-&gt;format, 0, 33, 33));
		apply_surface(playerX, playerY, player, screen);
		
		if(held){
			if(WPAD_BUTTON_HOME){
				done=true;
				SDL_FillRect(screen, 0, SDL_MapRGB(screen-&gt;format, 0, 0, 0));
			}
			
			if(WPAD_BUTTON_UP){
				playerY-=2;
			}
			
			if(WPAD_BUTTON_DOWN){
				playerY+=2;
			}
			
			if(WPAD_BUTTON_LEFT){
				playerX-=2;
			}
			
			if(WPAD_BUTTON_RIGHT){
				playerX+=2;
			}
		}
		
		
 
		// SDL_Flip refreshes the screen so it will show the updated screen
		SDL_Flip(screen);
        }
 
	// start cleanup() function
	cleanup();
 
    return 0;
}</pre>]]></description>
<dc:creator>Cypri</dc:creator>
<category>Coding</category><pubDate>Wed, 11 Aug 2010 03:22:26 +0200</pubDate></item>
</channel>
</rss>