Savebrush PNG Alpha doesn't work!

Discuss any general programming issues here
Post Reply
User avatar
fingus
Posts: 269
Joined: Fri Sep 16, 2011 9:53 am

Savebrush PNG Alpha doesn't work!

Post by fingus »

CopyBrush(iconnr, 1000)
trimbrush(1000)
ScaleBrush(1000,40,#KEEPASPRAT)
SaveBrush(1000, "ram:T/ico.png", IMGFMT_PNG)

gives me this:
Image
Alpha is missing!




source was this:
Image


And how this SMOOTH=TRUE tag is using in ScaleBrush(1000,40,#KEEPASPRAT)?
I tried it like in the Online-Help mentioned by ScaleBrush(1000,40,#KEEPASPRAT,{SMOOTH=true}) but does not work.
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Savebrush PNG Alpha doesn't work!

Post by airsoftsoftwair »

I can't reproduce this problem. Please provide a fully working (but small!) code snippet. Then I can see what's wrong there.
User avatar
fingus
Posts: 269
Joined: Fri Sep 16, 2011 9:53 am

Re: Savebrush PNG Alpha doesn't work!

Post by fingus »

I can't reproduce this problem. Please provide a fully working (but small!) code snippet. Then I can see what's wrong there.
Ok, do this:

1. Save the second PNG-Image from my first post named "n_sunny.png" and save it to ram:

2. Copy and execute this code:

Code: Select all

  @BRUSH 1,"ram:n_sunny.png", {loadalpha = True}
  CopyBrush(1, 2)
  trimbrush(2)
  ScaleBrush(2,40,#KEEPASPRAT)
  SaveBrush(2, "ram:ico.png", IMGFMT_PNG)


It will save a trimmed and resized icon to ico.png, but the borders are not filled with alpha-tranceparency anymore but with garbarge!



Here you can see the result without trim and resize after saving to png:

Image

Alpha is missing (white canvas) and garbarge around the object was added :-(
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Savebrush PNG Alpha doesn't work!

Post by airsoftsoftwair »

Hmm, where is the n_sunny.png image? I can't see it in your post!?
User avatar
fingus
Posts: 269
Joined: Fri Sep 16, 2011 9:53 am

Re: Savebrush PNG Alpha doesn't work!

Post by fingus »

oups, my fault!

here are the images again:

original with alpha working:

Image


scaled and trimmed one with missing alpha (savebrush, see above):

Image

and the same in original size:

Image

As you can see, something went wrong with the alpha saving.
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Savebrush PNG Alpha doesn't work!

Post by airsoftsoftwair »

Please read the documentation of SaveBrush(). You're using it in the wrong way. The correct syntax would be:

Code: Select all

SaveBrush(2, "ram:ico.png", 0, #IMGFMT_PNG)
Then it will work fine.
Post Reply