<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>jpg images crashes loading twice</title>
<description> I&amp;#039;m writting a GRRLIB tutorial for a Spanish web, and I&amp;#039;m finishing a chapter about textures.

The example code is a &quot;image/music&quot; viewer, and I found a problem with jpg images.

When I load a png image I haven&amp;#039;t found problems with the same code (only resolution diferent than x4 files are not showed, but it is known), but if the image is a jpg the file is showed once but if I try to show the same or a second diferent image the program crashes in loading function.
I&amp;#039;m writting a GRRLIB tutorial for a Spanish web, and I&amp;#039;m finishing a chapter about textures.

The example code is a &quot;image/music&quot; viewer, and I found a problem with jpg images.

When I load a png image I haven&amp;#039;t found problems with the same code (only resolution x4 files are not showed, but it is known), but if the image is a jpg the file is showed once but if I try to show the same or a second diferent image the program crashes in loading function.

void leeimagen(int i){
if (tex_foto!=NULL)
GRRLIB_FreeTexture(tex_foto);

nombre[0]=0;
strcat(nombre,DirActivo);
strcat(nombre,lista);
tex_foto = GRRLIB_LoadTextureFromFile(nombre);
GRRLIB_SetMidHandle(tex_foto,true);
}
and the code in main to show the image is:

if (tipos[archivo_actual]==TIPO_IMAGEN){
if(!leido) {
angulo = 0;
cursoractivo = 1;
leeimagen(archivo_actual);
leido = true;
}
if (tex_foto != NULL){
GRRLIB_SetMidHandle(tex_foto, true);
if ((angulo % 180) == 0){
sfx = 480.0/tex_foto-&amp;gt;w;
sfy = 365.0/tex_foto-&amp;gt;h;
} else {
sfy = 480.0/tex_foto-&amp;gt;h;
sfx = 365.0/tex_foto-&amp;gt;w;
}
}
if (tex_foto != NULL)
GRRLIB_DrawImg(320-stx,(210-sty)*sy,tex_foto,angulo,sfx*zoom,sy*sfy*zoom,GRRLIB_WHITE);
else
GRRLIB_DrawImg(320,210*sy,tex_error,0,1,sy*1.0,GRRLIB_WHITE);
}

By other hand, is it possible to show an image with resolution not multiply by 4 using a diferent library?


EDITED:
Seems it happens only with some jpeg images, but valid images.

I tried to put only two GRRLIB_LoadImageFromFile calls on main with the same jpeg image and program freeze, but only with some jpeg images. Another jpeg images works fine.</description><link>http://forum.wiibrew.org/read.php?11,68783,68783#msg-68783</link><lastBuildDate>Sun, 07 Jun 2026 16:45:59 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,68783,68828#msg-68828</guid>
<title>Re: jpg images crashes loading twice</title><link>http://forum.wiibrew.org/read.php?11,68783,68828#msg-68828</link><description><![CDATA[ Yes, if I do that you say, the image still crashing.<br />I thing it is a bug in the library.<br />By other hand, your library seems great. It is very interesting and I&#039;ll will try to use it in my programs.]]></description>
<dc:creator>wilco2009</dc:creator>
<category>Coding</category><pubDate>Thu, 08 Dec 2011 00:37:06 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,68783,68823#msg-68823</guid>
<title>Re: jpg images crashes loading twice</title><link>http://forum.wiibrew.org/read.php?11,68783,68823#msg-68823</link><description><![CDATA[ That behavior does sound very odd. What happens if you call the texture loading twice just own its own as a test - does it still crash?<br />Jpg does have a few file variations (so some loaders can’t cope) but from what you say, it loads and works first time. I don’t use things like grrlib myself, so I not going to be much help beyond this point.<br /><br />You could try<br /><a href="http://wiibrew.org/wiki/GameFramework" rel="nofollow">http://wiibrew.org/wiki/GameFramework</a><br />Look for x2 code files JPEGDEC. This is a lightweight jpg decoder; it’s no frills and will require more work with maybe less support for jpeg formats. I use it and it works well for me.]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Wed, 07 Dec 2011 22:14:44 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,68783,68805#msg-68805</guid>
<title>Re: jpg images crashes loading twice</title><link>http://forum.wiibrew.org/read.php?11,68783,68805#msg-68805</link><description><![CDATA[ I display only one file same time.<br />When user press a button, the program calls to function leeimagen, and in this function, before to load the new image, memory is released with GRRLIB_FreeTexture.<br /><br />The program works fine with pngs, and some jpg files, but with others GRRLIB_LoadTextureFromFile crashes the following time I call the function.<br />This happens when you user press next and then back.]]></description>
<dc:creator>wilco2009</dc:creator>
<category>Coding</category><pubDate>Tue, 06 Dec 2011 23:14:53 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,68783,68799#msg-68799</guid>
<title>Re: jpg images crashes loading twice</title><link>http://forum.wiibrew.org/read.php?11,68783,68799#msg-68799</link><description><![CDATA[ Your code snip looks ok, but you are using a single global variable named “tex_foto”<br />This limits you to just use one loaded image.<br />If that’s the way you designed it then that&#039;s fine, otherwise use another array like you have for the filename list "lista"]]></description>
<dc:creator>Titmouse</dc:creator>
<category>Coding</category><pubDate>Tue, 06 Dec 2011 20:41:20 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,68783,68783#msg-68783</guid>
<title>jpg images crashes loading twice</title><link>http://forum.wiibrew.org/read.php?11,68783,68783#msg-68783</link><description><![CDATA[ I&#039;m writting a GRRLIB tutorial for a Spanish web, and I&#039;m finishing a chapter about textures.<br /><br />The example code is a "image/music" viewer, and I found a problem with jpg images.<br /><br />When I load a png image I haven&#039;t found problems with the same code (only resolution diferent than x4 files are not showed, but it is known), but if the image is a jpg the file is showed once but if I try to show the same or a second diferent image the program crashes in loading function.<br />I&#039;m writting a GRRLIB tutorial for a Spanish web, and I&#039;m finishing a chapter about textures.<br /><br />The example code is a "image/music" viewer, and I found a problem with jpg images.<br /><br />When I load a png image I haven&#039;t found problems with the same code (only resolution x4 files are not showed, but it is known), but if the image is a jpg the file is showed once but if I try to show the same or a second diferent image the program crashes in loading function.<br /><br /><pre class="bbcode">void leeimagen(int i){
	if (tex_foto!=NULL)
		GRRLIB_FreeTexture(tex_foto);

	nombre[0]=0;
	strcat(nombre,DirActivo);
	strcat(nombre,lista<i>);
	tex_foto = GRRLIB_LoadTextureFromFile(nombre);
	GRRLIB_SetMidHandle(tex_foto,true);
}</i></pre>
and the code in main to show the image is:<br /><br /><pre class="bbcode">if (tipos[archivo_actual]==TIPO_IMAGEN){
	if(!leido) {
		angulo = 0;
		cursoractivo = 1;
		leeimagen(archivo_actual);
		leido = true;
	}
	if (tex_foto != NULL){
		GRRLIB_SetMidHandle(tex_foto, true);
		if ((angulo % 180) == 0){
			sfx = 480.0/tex_foto-&gt;w;
			sfy = 365.0/tex_foto-&gt;h;
		} else {
			sfy = 480.0/tex_foto-&gt;h;
			sfx = 365.0/tex_foto-&gt;w;
		}
	}
	if (tex_foto != NULL)
		GRRLIB_DrawImg(320-stx,(210-sty)*sy,tex_foto,angulo,sfx*zoom,sy*sfy*zoom,GRRLIB_WHITE);
	else
		GRRLIB_DrawImg(320,210*sy,tex_error,0,1,sy*1.0,GRRLIB_WHITE);
}</pre><br />By other hand, is it possible to show an image with resolution not multiply by 4 using a diferent library?<br /><br /><br />EDITED:<br />Seems it happens only with some jpeg images, but valid images.<br /><br />I tried to put only two GRRLIB_LoadImageFromFile calls on main with the same jpeg image and program freeze, but only with some jpeg images. Another jpeg images works fine.]]></description>
<dc:creator>wilco2009</dc:creator>
<category>Coding</category><pubDate>Mon, 05 Dec 2011 09:34:47 +0100</pubDate></item>
</channel>
</rss>