Picture.SaveAsWindowsBMP not transparent

I want to save a picture as BMP with a transparent background. The picture is transparent OK inside the app, but when I save it as BMP, the white becomes opaque.

BMP should support transparent pictures when it is 256 colors. What am I missing ? Or is it not supported ?

p.Save(ff,Picture.SaveAsWindowsBMP,100)

probably not supported.

you could try plugins like GraphicsMagick.

As far as I was aware… only GIF and PNG support transparent, BMP and JPG did not

and remember, if this is inside an XOJO app… it is no specific “format”, therefore White is transparent because XOJO says it is, but when you save it, it follows the rules of the format you saved it in

I googled a little because I had the same impression as Dave.
Allegedly you can save an alpha channel in BMP, but I get the feeling it’s not very common. So uncommon that you have to follow certain steps to get Photoshop (the image master) to save a transparent bmp.

I looked through the examples in GraphicsMagick but the write(folderitem) method does not seem to allow the choice of picture format. How do you save a BMP ?

[quote=131582:@Dave S]As far as I was aware… only GIF and PNG support transparent, BMP and JPG did not

and remember, if this is inside an XOJO app… it is no specific “format”, therefore White is transparent because XOJO says it is, but when you save it, it follows the rules of the format you saved it in[/quote]

BMP does support transparent. I was able to create transparent images in Paint .NET, no problem. Xojo does not seem to.

I need a transparent BMP to change icons under Windows. The alternative is to use .ico, and it is even more complicated to generate.

PNG ?

BMP does do 32 bit with alpha, but probably not all libraries support it.

Nope. Windows needs specifically BMP, .Ico, exe, dll, icl.

Exe and DLL use the internal resources of programs, icl is an icon library format. BMP is the only picture format one can use for folder icons.

Saving a transparent BMP is possible in VB .NET but before resorting to yet another DLL, I had hoped to find another solution, through Christian’s plugins or something else.

The BMP picture file saved by Xojo has a depth of 32 bits, but visibly the Alpha Channel gets lost :frowning:

GraphicsMagick doesn’t support everything here, but this generates an 32 bit image with mask as BMP file:

[code] dim f as FolderItem = SpecialFolder.Desktop.Child(“test.png”)
dim p as Picture = Picture.Open(f)

dim g as new GMImageMBS( new GMGeometryMBS(p.Width, p.Height), new GMColorGrayMBS(1.0))

g.type = g.TrueColorMatteType
g.matte = True
g.magick = “BMP”

g.SetPicture(p, 0, 0)
g.SetPictureMask(p.mask.invertMBS, 0, 0)

f = SpecialFolder.Desktop.Child(“test.bmp”)
g.write(f)[/code]

[quote=131599:@Christian Schmitz]GraphicsMagick doesn’t support everything here, but this generates an 32 bit image with mask as BMP file:

[code] dim f as FolderItem = SpecialFolder.Desktop.Child(“test.png”)
dim p as Picture = Picture.Open(f)

dim g as new GMImageMBS( new GMGeometryMBS(p.Width, p.Height), new GMColorGrayMBS(1.0))

g.type = g.TrueColorMatteType
g.matte = True
g.magick = “BMP”

g.SetPicture(p, 0, 0)
g.SetPictureMask(p.mask.invertMBS, 0, 0)

f = SpecialFolder.Desktop.Child(“test.bmp”)
g.write(f)[/code][/quote]

Thank you, but it does not work. The white background remains opaque :frowning:

If I may ask, why are you dealing with BMP at all? PNG seems to be a good all-purpose format with no downsides.

Garth, I explained that above. Because I must use that format… Or ico…

Well. If I may, it takes 10 seconds in VB … Sometimes, Xojo for Windows can be a pain in the ynw…

See:

[quote=131594:@Michel Bujardet]Windows needs specifically BMP, .Ico, exe, dll, icl.

Exe and DLL use the internal resources of programs, icl is an icon library format. BMP is the only picture format one can use for folder icons.[/quote]

I’m just gonna leave this here:
http://youtu.be/fL70CIHY6RQ?t=12s

[quote=131622:@Tim Parnell]See:

I’m just gonna leave this here:
http://youtu.be/fL70CIHY6RQ?t=12s[/quote]

Here we go again. When will you stop this silly Mac bullsht ? This is a cross platform environment, you dumb dumb. So you got your toy and want it be known ? Alright kid. Now go play somewhere else instead of bugging people who work :confused:

And, the pain in the thing I refer to is also the result of this constant Windows bashing going on here ! At one point, prejudice becomes unbearable.

I have been using a Mac since day one just as a PC, and am sick and tired of ignorants.

Fortunately I have a long-standing habit of never taking technical advice from people named “Daphne”.

No, I was looking for something a bit more specific, your description was a bit vague. PNG certainly is usable in the Windows environment. I think you are talking about using BMP’s in your Xojo-created .exe so another program can access it via WinAPI to extract icons out of? Or am I wrong?

“Must use that format” left me sort of twisting in the wind; the question was “why”.

The reason is extremely simple : a Windows folder icon has to use basically two formats, either ico (plain or inside .exe, dll or icl), or BMP. So if I want to create a program that changes a folder appearance, I have to find a way either to create transparent BMP, or ico. The first should be fairly easy, the second is much more involved.

The exact format the BMP must be in is 256 indexed colors. It takes about 3 lines in VB .NET to do. I had naively hoped Xojo would be able to do the same. Now I guess I will have to use yet again a VB DLL I’ll call from Xojo. You know, it does take commitment to use Xojo, sometimes :frowning:

I did try to set the icon as png, but it simply does not work (go figure).

Sigh : <https://xojo.com/issue/35496>

Probably a question for one of the programmers but … “How do they do it?” Meaning if I put a .PNG (or any image that has transparency) into the icon(s) in App, when I look at a compiled program the transparency is there. What are they doing to keep the transparency because I can then set that icon to show on folders & my file type.

FYI, you can use any image filetype with Win 8.1

[quote=131712:@Jym Morton]Probably a question for one of the programmers but … “How do they do it?” Meaning if I put a .PNG (or any image that has transparency) into the icon(s) in App, when I look at a compiled program the transparency is there. What are they doing to keep the transparency because I can then set that icon to show on folders & my file type.

FYI, you can use any image filetype with Win 8.1[/quote]

What I need is not an icon for my app. And from what I can tell, the transparency is simply turned into a mask. You can see it by clicking into the Mask button of the app icon editor.

I need to set the icon for a folder independently of any Xojo app at all, at the Windows system level so then it will show with that icon on any Windows system. As I tried to explain above, that does require .ico or .bmp. FYI, I verified that with Windows 8.1 first thing.
See http://msdn.microsoft.com/en-us/library/windows/desktop/cc144102(v=vs.85).aspx

Since Xojo cannot save 256 indexed color BMP, I had to use a DLL written in VB .NET which I call from my Xojo program, that loads the non-transparent picture, turns it transparent, and saves it back. The same can be achieved with a VB Console program.

So to answer my original question, Xojo does not support transparency for bmp saving.

Using an image that have parts of it “transparent” (no color in some part of the image) as Windows XP custom folder leads to these parts with white ;-:slight_smile:

I do not know how to set a custom icon on WIndows 8 / 8.1, yet, so I cannot tell. I will read the shared link (re-read, I already read it, but I was not able to make it work, so I certainly mis-read something or skip a part of the text).