Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#201067 - 28/01/2004 14:42 Editing 32-bit Windows bitmaps with alpha channel
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
Any applications out there that can edit a BMP file that's got an alpha channel (and preserve the alpha channel)? Preferably free.

I'm trying to spruce up a toolbar for an application that I'm hacking on. It uses 32-bit toolbar buttons, so it'd be even better if the application had a good zoom/grid mode.
_________________________
-- roger

Top
#201068 - 29/01/2004 05:57 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: Roger]
peter
carpal tunnel

Registered: 13/07/2000
Posts: 4180
Loc: Cambridge, England
Any applications out there that can edit a BMP file that's got an alpha channel (and preserve the alpha channel)? Preferably free.
Gimp understands both BMPs and alpha channels, so although I can't find a definite reference to it understanding BMPs with alpha channels, it sounds worth a shot. Some psycho has ported it to Windows, but I bet the Linux one is more stable.

Peter

Top
#201069 - 29/01/2004 06:56 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: peter]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
understanding BMPs with alpha channels

Gimp 1.2.3 certainly doesn't: it loads the bitmap successfully, but only shows 3 channels (R, G and B).

Time to upgrade my Debian box to sarge, maybe?

Alternatively, I think I might cobble something together to separate the alpha channel out as a separate monochrome bitmap, and then recombine them after I've edited both (which I think I can do by telling PSP to load the separate bitmap as an alpha channel).

_________________________
-- roger

Top
#201070 - 29/01/2004 07:05 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: Roger]
peter
carpal tunnel

Registered: 13/07/2000
Posts: 4180
Loc: Cambridge, England
Gimp 1.2.3 certainly doesn't: it loads the bitmap successfully, but only shows 3 channels (R, G and B).

Time to upgrade my Debian box to sarge, maybe?
Might not help. I've just tried 1.2.5 and that doesn't grok it either . Shame.

Peter

Top
#201071 - 30/01/2004 03:26 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: Roger]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
I think I might cobble something together to separate the alpha channel out as a separate monochrome bitmap

This works fine: I can load the RGB bitmap into Paintshop Pro, and then load the alpha channel separately (I wrote something that exports it as a 24bpp grayscale bitmap for simplicity).

I can then edit the bitmap, although I have to edit the RGB layer and the alpha layer separately (e.g. when moving tiles) which is a pain, but I can live with it.

Unfortunately, I can't find any way to get PSP to save the damn alpha layer as a monochrome .BMP file, which means that there's not much point in me writing the rest (24+A -> 32) of the utility.

Bugger.

Any more suggestions?

I can't even find a way to get the Gimp to load the second bitmap as an alpha channel.
_________________________
-- roger

Top
#201072 - 31/01/2004 10:08 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: Roger]
hybrid8
carpal tunnel

Registered: 12/11/2001
Posts: 7738
Loc: Toronto, CANADA
Photoshop. Not free.

However I don't see why PSP should not be able to handle the job. As long as it supports editing 24bit with transparency, then you should be able to manually get what you want. The transparency is defined with an 8bit alpha channel, whether or not it shows you that channel from its interface. And whether or not it saves compatible BMP files.

The two methods I see: 1 manual pixel pushing, making two images (as you have already touched upon) and 2, creating one image with transparency, saving it in a format that preserves that transparency, and then finding a converter on the net, or making your own to rework the headers nd byte order into your BMP format. Photoshop files, TIFF, TARGA and PNG should be suitable formats for the initial save.

Method #1 is what I use (with Photoshop) to make Icons with an alpha channel for Mac OS X. I don't have the time to describe the complete process, but basically I work on an image in layers, all of which have transparency, some of which have only 100% opaque pixels and some which have variable transparency. I always keep my source file layered - this is good in case you need to come back later and make edits you may not be able to make once flattening or merging some portions.

Using Photoshop it's very easy to select only the portions of the canvas containing pixels (control (or is it alt?) clicking the desired layer in the layer palette will do this). There should be something similar is PSP. Once you have that election (which itself knows about the transparency values of the pixels it contains), you can (with Photoshop) save the selection into a channel. This can be your mask or may need to be inverted to create your mask (the icon software I use treats black as "show" and white as "hide" with values in between being translucent of course). Now you'll also need to save the image that will be masked. I do this by creating a new black background behind it and then saving it flat. The black background is there because the mask will be used so that portions of the image taht are translucent will darken the background they're placed on, not lighten it. This way a shadow will be invisible when placed on a black background, instead of showing up as greys and white (this is what would happe if the file had been saved composited onto a white background). However, if your item is a highlight and not a shadow, you'd want the reverse to be true.

I add both the imge and the mask into the icon program which support locations for each. Either that or they're used in custom software and dealt with by the programmer and Mac OS's support for masks.

I hope the info helps, even if not specific to your intended usage. Again, the process may need to change depending on how your target will use its files.


Bruno
_________________________
Bruno
Twisted Melon : Fine Mac OS Software

Top
#201073 - 31/01/2004 11:10 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: hybrid8]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
However I don't see why PSP should not be able to handle the job.

It turns out that it's because PSP can't handle 32-bpp raster images. According to JASC support:

Paint Shop Pro does not support 32-bit images. Hence it will not support the format that you are trying to create.


More specifically, it'll do all the layering and stuff while editing the file, but when you go to save it to a BMP or PNG file, it flattens everything down to 24 bits, and strips out the alpha channel.

This means that I can't use it to save a 32-bpp PNG file (because it doesn't actually seem to write them) even if I spend the time to write a PNG to BMP convertor (which should be trivial, given libpng).

So, frankly, I think I'll opt for manual pixel pushing -- editing the 24bpp image and the alpha separately, and then writing a utility to merge them back together. This way I get to use the copy of PSP5 that I've had for years, and I don't need to spend any more money.
_________________________
-- roger

Top
#201074 - 31/01/2004 12:22 Re: Editing 32-bit Windows bitmaps with alpha channel [Re: Roger]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Can you post a sample image?
_________________________
Bitt Faulk

Top
#201075 - 31/01/2004 12:24 Re: Editing 32-bit Windows bitmaps with alpha channel [Re: wfaulk]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
Sure, but there's nothing particularly clever about the image format.


Attachments
200048-toolbar32.bmp (130 downloads)

_________________________
-- roger

Top
#201076 - 31/01/2004 12:37 Re: Editing 32-bit Windows bitmaps with alpha channel [Re: Roger]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
...and the (admittedly quite nasty) code that I cobbled together the other day to separate out the channels.



Attachments
200050-bmp32.cpp (322 downloads)

_________________________
-- roger

Top
#201077 - 31/01/2004 12:42 Re: Editing 32-bit Windows bitmaps with alpha channel [Re: Roger]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Other than I didn't have a sample to test.

Is this what you're looking for? I don't have a good way easily available to test it.


Attachments
200051-toolbar32.png (180 downloads)

_________________________
Bitt Faulk

Top
#201078 - 31/01/2004 12:50 Re: Editing 32-bit Windows bitmaps with alpha channel [Re: wfaulk]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
Is this what you're looking for?

Not really. I can (assuming I do a little hacking with libpng) already turn a ABGR bitmap file into an RGBA PNG file and vice versa. What I'm having trouble with is finding something that will let me edit them interactively.

Or am I missing something and you're showing me something else?
_________________________
-- roger

Top
#201079 - 31/01/2004 12:56 Re: Editing 32-bit Windows bitmaps with alpha channel [Re: Roger]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
You just want something that will natively edit ABGR bmps rather than having to do conversions manually at either end?

Well, my tool should be able to do that, too. GraphicConverter. Of course, you'll have to invest in a Mac, and transferring the files between the two computers would probably be at least as intensive as doing the conversion back and forth.
_________________________
Bitt Faulk

Top
#201080 - 31/01/2004 13:51 Re: Editing 32-bit Windows bitmaps with alpha channel [Re: wfaulk]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
You just want something that will natively edit ABGR bmps rather than having to do conversions manually at either end?

Yes, because it's not only doing the manual conversions.

If I'm just doing rudimentary editing, for example swapping buttons around, or stealing some buttons from another app until I can pay for or some original artwork, then it's a PITA to have to do it all on pairs of bitmaps.

Obviously, if it's more intensive editing, then I'd be doing it on multiple layers, which is almost the same amount of work as multiple bitmaps.
_________________________
-- roger

Top
#201081 - 31/01/2004 14:44 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: Roger]
peter
carpal tunnel

Registered: 13/07/2000
Posts: 4180
Loc: Cambridge, England
Not really. I can (assuming I do a little hacking with libpng) already turn a ABGR bitmap file into an RGBA PNG file and vice versa. What I'm having trouble with is finding something that will let me edit them interactively.
But once it's an RGBA PNG then the Gimp will edit it fine. Unless I'm missing something.

Peter

Top
#201082 - 31/01/2004 15:39 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: peter]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
But once it's an RGBA PNG then the Gimp will edit it fine. Unless I'm missing something.

Good spot. Indeed it will. Time to cobble together a BMP <-> PNG convertor that deals with 32-bpp, unless I can find one on the 'net.
_________________________
-- roger

Top
#201083 - 31/01/2004 15:50 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: Roger]
peter
carpal tunnel

Registered: 13/07/2000
Posts: 4180
Loc: Cambridge, England
Good spot. Indeed it will. Time to cobble together a BMP <-> PNG convertor that deals with 32-bpp, unless I can find one on the 'net.
Imagemagick's convert(1)? I'd guess that's what Bitt used.

Peter


Attachments
200081-foonly.bmp (110 downloads)


Top
#201084 - 31/01/2004 16:13 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: peter]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
Imagemagick's convert(1)?

What incantation do you need to use? I can't get it to keep the alpha channel in the BMP->PNG conversion. I've not tried the other direction yet.
_________________________
-- roger

Top
#201085 - 31/01/2004 16:32 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: Roger]
peter
carpal tunnel

Registered: 13/07/2000
Posts: 4180
Loc: Cambridge, England
What incantation do you need to use? I can't get it to keep the alpha channel in the BMP->PNG conversion. I've not tried the other direction yet.
I just used "convert thing.bmp thing.png". What version of Imagemagick have you got? Mine is 5.5.8, though there seems to be a 6.0.0 now.

Peter

Top
#201086 - 31/01/2004 16:58 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: peter]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
What version of Imagemagick have you got?

5.4.4. I'll build a 6.0.0 tomorrow and see if I have any luck...
_________________________
-- roger

Top
#201087 - 01/02/2004 02:40 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: peter]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Nah. Like I said, GraphicConverter. FWIW, it seems netpbm doesn't understand 32-bit BMPs, either.
_________________________
Bitt Faulk

Top
#201088 - 01/02/2004 03:59 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: peter]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
though there seems to be a 6.0.0 now.

Which doesn't appear to work properly -- it creates an empty alpha channel in the PNG (and to get that I had to "convert thing.bmp png32:thing.png"). I'll grab a copy of 5.5.8, and see if I can get that to work.
_________________________
-- roger

Top
#201089 - 01/02/2004 04:12 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: Roger]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
I'll grab a copy of 5.5.8, and see if I can get that to work

Nope. 5.5.7 -- the latest stable one listed on http://www.imagemagick.org/ -- still strips the alpha channel out, if I run it the way you did.

_________________________
-- roger

Top
#201090 - 01/02/2004 14:47 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: Roger]
ricin
veteran

Registered: 19/06/2000
Posts: 1495
Loc: US: CA
Uhm. Doesn't convert -transparent black toolbar32.bmp toolbar32.png work?
_________________________
Donato
MkII/080000565
MkIIa/010101253
ricin.us

Top
#201091 - 01/02/2004 14:49 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: ricin]
ricin
veteran

Registered: 19/06/2000
Posts: 1495
Loc: US: CA


No?


Attachments
200248-toolbar32.png (210 downloads)

_________________________
Donato
MkII/080000565
MkIIa/010101253
ricin.us

Top
#201092 - 01/02/2004 15:27 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: ricin]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
convert -transparent black

No, because it strips out the alpha channel (which is an 8-bit quantity) and replaces it with a 1-bit mask. Unless the man page is not telling me something.
_________________________
-- roger

Top
#201093 - 01/02/2004 17:45 Re: Editing 32-bit Windows bitmaps with alpha chan [Re: ricin]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Well, there would be no guarantee that the transparent part would be black, or even any single color, not to mention ignoring the levels of transparency. For example, look a magnified version of the image you posted back:



Look at all those nearly-black artifacts, especially on the X and the disk.


Attachments
200279-alpha.png (159 downloads)

_________________________
Bitt Faulk

Top