Transparent Color

Started by deetee, November 05, 2010, 01:18:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DCelso

#15
I found the problem, pnginfo (of pngtool) sais that your format is:

A02.png...
Image Width: 60 Image Length: 44
 Bitdepth (Bits/Sample): 8
 Channels (Samples/Pixel): 3
 Pixel depth (Pixel Depth): 24
 Colour Type (Photometric Interpretation): RGB
 Image filter: Single row per byte filter
 Interlacing: No interlacing
 Compression Scheme: Deflate method 8, 32k window
 Resolution: 0, 0 (unit unknown)
 FillOrder: msb-to-lsb
 Byte Order: Network (Big Endian)
 Number of text strings: 0 of 0


You are using three channels (24 bits depht), and it seems that Bennugd does not support transparent color in this kind of png. mtpaint seems that yes.

For 8 bits (or any indexed png) you need a png with this format.

A08.png...
 Image Width: 60 Image Length: 44
 Bitdepth (Bits/Sample): 8
 Channels (Samples/Pixel): 1
 Pixel depth (Pixel Depth): 8
 Colour Type (Photometric Interpretation): PALETTED COLOUR (59 colours, 0 transparent)
 Image filter: Single row per byte filter
 Interlacing: No interlacing
 Compression Scheme: Deflate method 8, 32k window
 Resolution: 2835, 2835 (pixels per meter)
 FillOrder: msb-to-lsb
 Byte Order: Network (Big Endian)
 Number of text strings: 0 of 0


A02.png...
 Image Width: 60 Image Length: 44
 Bitdepth (Bits/Sample): 2
 Channels (Samples/Pixel): 1
 Pixel depth (Pixel Depth): 2
 Colour Type (Photometric Interpretation): PALETTED COLOUR (4 colours, 0 transparent)
 Image filter: Single row per byte filter
 Interlacing: No interlacing
 Compression Scheme: Deflate method 8, 32k window
 Resolution: 2835, 2835 (pixels per meter)
 FillOrder: msb-to-lsb
 Byte Order: Network (Big Endian)
 Number of text strings: 0 of 0

Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/

DCelso

#16
Quote from: SplinterGU on November 08, 2010, 06:07:20 PM
...
1) 32bits png are loaded as 16bits in 16bit screen mode (set_mode)
2) in your sample/fix your forget delete_text for the writes
3) for transparent png, you need set alpha channel on the png from your graphic editor.
In my example you can see that:
* the point 1 is not correct of all, 32 bits png in 16 bit screen mode round its alpha channel to 0 or 255.
* the point 3 is not neccesarily so, if you use alpha channel in png file you see forced to use 32 bits, and it is not neccesary, you can use "indexed" png (<=8 bits depth) knowing that Bennu uses the first color of your indexed palette as transparent because alwais is the 0.
In the "A08bis.png" file you can see that the first color of the palette is the RED and bennu uses it as transparent to draw it.

Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/

SplinterGU

dcelso, again...

bennugd support transparent on png, you need use channel alpha, alpha < 128 are bits transparent.
in index color, 0 is transparent.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

DCelso

Quote from: SplinterGU on November 08, 2010, 10:32:15 PM
dcelso, again...

bennugd support transparent on png, you need use channel alpha, alpha < 128 are bits transparent.
in index color, 0 is transparent.
¿?no entiendo, es justo lo que dije.
Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/

SplinterGU

entonces entendi mal... :D
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

DCelso

Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/

deetee

Hi all!

Thanks for all helpful hints and codes/pictures (DeCelso) - and also thanks for the "spanish language lessons" (due to your smilies I guess I didn't start some guru-dispute).

DeCelso's graphics are working - especially A032.png seems to be very universal (even transparent on windows-photo-viewer).

On my WIZ there is no crash any more (this was my bad memory handling). A08bis.png was shown transparent, A24 and A32 are not shown at all. Instead I got a second green background-rectangle (300x220, starting at ~280,170) - seems to be caused by pic5 (A24).

So I have to ...
* ... resolve how to make working PNGs (like A08bis or A32) with mtpaint.
* ... resolve why (instead of the second PNG) another shifted green background rectangle occurs (on my WIZ).

Till soon - thanks so far
deetee

deetee

Yes! - it is working.

I took DeCelso's A32.png and edited it with mtpaint - then I saved without changing the transparent preferences. Even reducing the palette to 4 or 16 colors works. As I am not a specialist regarding graphics, channels etc. - it is working (even on my WIZ). Thank you DeCelso for putting  this magic in my PNG.

Only one point has to be clarified:
* What causes the second green background rectangle? I guess I did something bad with the WIZ/bennu graphic memory?

TIA
deetee

deetee

Sorry for this "triple-reply" but I think I solved the last point now.

I forget to unload one map - this seems to cause memory problems.

So my final piece of code is:
process main()
private
int escape=0, was_clicked=0, mx=0;
string str1="", str2="";
int square, pic6;
begin
  //  set_mode(320,240,8);
  square=new_map(300,220,16); map_clear(0,square,rgb(0,255,0));

  pic6=png_load("gfx/new3.png");

repeat
  str1="WIZ-Key:"+itoa(key_query())+" Character: "+chr(ascii)+" "+itoa(ascii);
  write_string(0,320/2,200/2,4,&str1);

  if((was_clicked==1) && (! mouse.left))
   str2="x:"+itoa(mouse.x)+" y:"+itoa(mouse.y);
   write_string(0,320/2,240/2,4,&str2);
   mx=mouse.x;
  end;
  was_clicked = mouse.left;

  put(0,square,160,120);
  put(0,pic6,50,50);

  if(key(_ESC) or joy_getbutton(0,KEY_MENU) or (mx>300)) escape=1; end
  frame;
until(escape);

unload_map(0,pic6);
let_me_alone();
end


Thank you all for your help - without it - I would have given up.
deetee

DCelso

Ok, perhaps your kind of PNGs may be that in next versions of bennugb runs well, I sent to SplingerGU a fix code suggestion to support them.

Thanks to you for share it.

Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/

SplinterGU

Quote from: DCelso on November 09, 2010, 02:48:33 PM
Ok, perhaps your kind of PNGs may be that in next versions of bennugb runs well, I sent to SplingerGU a fix code suggestion to support them.

Thanks to you for share it.



I waiting fix, I can't add "if (... depth == 16 ... )" where is "else" in the original code, how you suggest.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2