bmap_save plugin?

Posted By: hopfel

bmap_save plugin? - 01/05/11 15:01

Hey guys,
I know this question was asked many times before,
but I just can't find the thread so I have to ask again:

Im looking for a plugin I can save bitmaps with
not only in the size with a power of two.
Is there something like this?
Would be very helpful. :3
~Greets
Posted By: Rei_Ayanami

Re: bmap_save plugin? - 01/05/11 15:07

bmap_save

"Die jpg-Qualität läßt sich nicht anpassen und die Bildgrösse muß ein Vielfaches von 8 sein"

PNG zum Beispiel geht mit jeder Größe wink
Posted By: hopfel

Re: bmap_save plugin? - 01/05/11 15:19

Es steht aber auch:
Quote:
The allocated bitmap size (always a power of two) is saved in engine versions up to 7.85; from 7.86 on the size given in the BMAP definition is saved


Und wenn dem trotzdem nicht so ist muss ich mich wundern wieso meine 80*85 PNG-Bitmap trotzdem als 128*128 gespeichert wird. O.o
Könnte es sein, dass das erst ab A8 geht?

Posted By: Widi

Re: bmap_save plugin? - 01/05/11 15:24

Vielleicht hilft dir der folgende Code etwas, damit kannst du tga files speichern.
Code:
void SCHREIBE_TGA_8(var shadow_byte)                                                               // schreibe char
{
	file_asc_write (Filehandle,shadow_byte);
}
	
void SCHREIBE_TGA_16(var shadow_short)                                                             // schreibe unsigned shadow_short
{
	file_asc_write (Filehandle,shadow_short&255);
	file_asc_write (Filehandle,(shadow_short>>8)&255);
}
	
void SCHREIBE_TGA_BILD(BMAP* MY_BMAP,STRING* MY_STR)                                               // ***** SPEICHERT DAS BILD IM TGA - FORMAT ***** //
{
	var format = 0;
	var pixel = 0;
	var pixel_alpha = 0;
	
	Temp_vec1.x = bmap_width  (MY_BMAP);
	Temp_vec1.y = bmap_height (MY_BMAP);
	
	format = bmap_lock (MY_BMAP,0);
	
	Filehandle = file_open_write (MY_STR);
	//----------------------------------------------------------------------------------------------// schreibe Header der tga Datei
	SCHREIBE_TGA_8(0);
	SCHREIBE_TGA_8(0);
	SCHREIBE_TGA_8(2);                                                                              // ild Typ: 10 = RLE komprimierte tga, 2 = unkomprimierte tga
	SCHREIBE_TGA_16(0);
	SCHREIBE_TGA_16(0);
	SCHREIBE_TGA_8(0);
	SCHREIBE_TGA_16(0);
	SCHREIBE_TGA_16(0);
	SCHREIBE_TGA_16(Temp_vec1.x);                                                                   // Breite
	SCHREIBE_TGA_16(Temp_vec1.y);                                                                   // Höhe
	SCHREIBE_TGA_8(32);                                                                             // 24 oder 32 für Alphakanal
	SCHREIBE_TGA_8(0);
	//----------------------------------------------------------------------------------------------// schreibe Bilddaten der tga Datei
	for (i=0; i < Temp_vec1.x * Temp_vec1.y; i++)
	{
		pixel = pixel_for_bmap (MY_BMAP, i%Temp_vec1.x, (Temp_vec1.y-1)-integer(i/Temp_vec1.x));
		pixel_to_vec (Temp_col1,pixel_alpha,format,pixel);
		pixel_alpha *= 2.55;                                                                         // wandle alpha von 0 bis 100 --> 0 bis 255
		SCHREIBE_TGA_8 (Temp_col1.blue);                                                             // b
		SCHREIBE_TGA_8 (Temp_col1.green);                                                            // g
		SCHREIBE_TGA_8 (Temp_col1.red);                                                              // r
		SCHREIBE_TGA_8 (pixel_alpha);                                                                // alpha
	}
	file_close(Filehandle);
	bmap_unlock(MY_BMAP);
}


Rufe einfach "SCHREIBE_TGA_BILD(bmap_pointer,speichername);" zum speichern auf. Diese Files sind genau so gross wie das ursprüngliche Bild.

EDIT: du musst noch einen Vector (Temp_vec1) und eine Color (Temp_col1) definieren...
Posted By: hopfel

Re: bmap_save plugin? - 01/05/11 16:06

(i und Filehandle mussten auch noch definiert werden)
Das wäre genau das was ich suche, aber aus irgendeinem Grund crasht die Funktion "SCHREIBE_TGA_BILD" wenn ich sie ausführe...
Ich habe ka was es sein könnte, ich kann im Code keine Fehler erkennen. smirk
Aber vielen dAnk schonma. ^^
Posted By: Widi

Re: bmap_save plugin? - 01/05/11 16:57

Hab`s gerade nochmals getestet, funktioniert bei mir.
Hast du beim Speichername auch das .tga angehängt? (zb. test_bmap.tga)
hat dein Ursprungsbild einen Alphachannel? wenn nicht ändere folgende Zeile:

SCHREIBE_TGA_8(32);

zu:

SCHREIBE_TGA_8(24);
Posted By: hopfel

Re: bmap_save plugin? - 01/05/11 17:21

Oke, Problem gelöst, ich war mal wieder extrem unfähig und habe
den Farbvector mit COLOR* anstatt mit COLOR definiert. --,,--
Aber jetzt funktionierts wunderbar. grin
Vielen herzlichen Dank! smile
Posted By: Widi

Re: bmap_save plugin? - 01/05/11 17:32

Gerne
© 2024 lite-C Forums