News: 11 March 2016 - Forum Rules, Mobile Version
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia

Author Topic: Any good editors that save 16bit BMPs?  (Read 1722 times)

weissvulf

  • Sr. Member
  • ****
  • Posts: 324
  • Good news! An anomaly solved the enigma.
    • View Profile
Any good editors that save 16bit BMPs?
« on: November 29, 2017, 09:58:56 pm »
Hope this is the right section for this question. I'm wondering if anyone knows a common (preferably free) photo editor that will save BMP images in 16bit format.

I'm trying to write a tool that handles Playstation image files. The problem is that 16bit images are very common in Playstation games, and I can't locate a decent photo editor that saves a 16bit BMP. They all upscale to 24bit which hinders re-insertion into the game when translating text graphics.

There's little point in coding a 16bit TIM to BMP converter if there are no common tools that will let people edit the BMPs. It might make more sense to use an automatic 16<>24 scaling step in the conversion process, eliminating 16bit BMPs altogether.

Gemini

  • Hero Member
  • *****
  • Posts: 1957
  • 時を越えよう、そして彼女の元に戻ろう
    • View Profile
    • Apple of Eden
Re: Any good editors that save 16bit BMPs?
« Reply #1 on: November 29, 2017, 10:35:06 pm »
The official TIM plugin for Photoshop handles the conversion, starting from true color pictures. In other words, you don't need actual 16 bit bitmaps.
I am the lord, you all know my name, now. I got it all: cash, money, and fame.

FAST6191

  • Hero Member
  • *****
  • Posts: 2269
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #2 on: November 30, 2017, 07:13:50 am »
In the advanced options of export file as for GIMP I am given R5G6B5 and X1R5G5B5 options for 16 bit BMP (may need to select Windows BMP from the list).

weissvulf

  • Sr. Member
  • ****
  • Posts: 324
  • Good news! An anomaly solved the enigma.
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #3 on: November 30, 2017, 02:33:13 pm »
Thank you both for this info :)
I haven't used GIMP in a while, but I will check that out. I read a thread which suggested that it doesn't support 16bit BMPs, but it may have been old/inaccurate info.

I'm leaning towards bypassing 16bit BMPs as Gemini mentions. The BMP format documentation shows that 16bit uses bit-masks in the header to define each color channels (ie the R5 G6 B5 and X1 R5 G5 B5 that GIMP mentions), but I've found some 16bit BMPs which don't seem to include the bit-masks at all, yet still function. It would probably be easier to make a color scaler than to implement detection and execution for color masks that may or may not exist.

Thanks again, appreciate the info!

Squall_FF8

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #4 on: December 29, 2017, 03:45:35 am »
The other option is to make a converter yourself - input: 24bit, output 16bit.

The trick is to know how to convert 8bit R/G/B to 5 or 6 bits. Its simple right-shift by 3 (or 2 in 6 bits)

weissvulf

  • Sr. Member
  • ****
  • Posts: 324
  • Good news! An anomaly solved the enigma.
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #5 on: December 29, 2017, 06:35:24 pm »
Quote
input: 24bit, output 16bit.
Hi Squall  :) Thanks for the input. That's basically what I ended up doing.

I think photo editors use the bit-shifting technique you mention to convert color values, probably because it's fast. I was a bit nervous about accuracy when going 5 to 8bit. For example, take a pure white 11111 and left-shift 3 (11111000) would equal 248 instead of the ideal 255. This color shift is slightly noticeable in certain combinations. Is there a way to do that conversion just as fast without losing any accuracy? I used "color x 8.22 rounded", but it is significantly slower. 

wanzer

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #6 on: December 29, 2017, 08:38:42 pm »
I remember these programs called Irfanview, and NeoPaint. Both handle 16-32 bit conversion.

Squall_FF8

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #7 on: December 30, 2017, 08:15:14 am »
Hi Squall  :) Thanks for the input. That's basically what I ended up doing.

I think photo editors use the bit-shifting technique you mention to convert color values, probably because it's fast. I was a bit nervous about accuracy when going 5 to 8bit. For example, take a pure white 11111 and left-shift 3 (11111000) would equal 248 instead of the ideal 255. This color shift is slightly noticeable in certain combinations. Is there a way to do that conversion just as fast without losing any accuracy? I used "color x 8.22 rounded", but it is significantly slower.
I thought you need 24->16 bit conversation, what you talk about is the 16->24 bit :D
Converting 24->16 is easy because you drop few bits. The opposite conversation is a little bit tricky, because you add few bits, and you can alter what value to use for extra bits.

Your approach of linear interpolation (x8.22) is good because it gives good results (31->255, 0->0). It maybe slow on large pictures or slow processors. If speed is your goal I will suggest:
Code: [Select]
X >> 3 + 7, where X is R/G/B value of 5 bitsIt is fast, but 0->7 ... That should not be visible for the eye, but if that is a problem, you need to check: if X = 0 then Result = 0

I remember these programs called Irfanview, and NeoPaint. Both handle 16-32 bit conversion.
I use IrfanView (its free  program and the best picture viewer) and it has conversation to 5-6-5 only.

weissvulf

  • Sr. Member
  • ****
  • Posts: 324
  • Good news! An anomaly solved the enigma.
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #8 on: December 30, 2017, 02:56:28 pm »
Thanks Wanzer (FontMission fan?) and Squall. This issue came from trying to find a 'tool-chain' for translators who need to edit 16bit Playstation images and then re-insert the translated image. Most image editors will open 16bit images, but very few seem to SAVE in 16bit format.

I was making a simple TIM to BMP converter and I wondered if it was better to convert between 16TIM and 16BMP, or eliminate the 16BMP format altogether and convert between 16TIM and 24BMP.

I checked Irfanview and NeoPain. As far as I can tell, neither saves in 16bit BMP format. Infraview has an option "(24 BPP, simple RGB-565)", but it seems to output 24bit images. Maybe I'm missing something.

DragonSpikeXIII

  • Full Member
  • ***
  • Posts: 200
  • Team NEMO
    • View Profile
    • Project NEMO
Re: Any good editors that save 16bit BMPs?
« Reply #9 on: December 31, 2017, 01:16:52 am »
I see that GIMP has been mentioned already, and it does export images in 16-bits (R5 G6 B5, A1 R5 G5 B5 [can't pick this one though for some reason,, or X1 R5 G5 B5) as well as 24-bit and 32-bits.

I just tested it and converted a 24-bit image to 16-bit. It worked just fine but the end result was slightly darker, don't know if this is normal.

optiroc

  • Jr. Member
  • **
  • Posts: 38
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #10 on: January 01, 2018, 11:13:21 am »
When scaling up values from lower to higher bit depth, left bit replication is a simple and quick solution.

weissvulf

  • Sr. Member
  • ****
  • Posts: 324
  • Good news! An anomaly solved the enigma.
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #11 on: January 01, 2018, 03:12:59 pm »
Quote
GIMP ... does export images in 16-bits (R5 G6 B5, A1 R5 G5 B5 [can't pick this one though for some reason,, or X1 R5 G5 B5
Gimp is the only editor I've found so far that does. I don't think the BMP format supports Alpha, which may be why 'A1 R5 G5 B5' is greyed out.
An interesting note, as far as I can tell TIMviewer will not convert these Gimp 16-BMPs back to TIMs. The standard format for 16bit BMPs has the 'compression' tag set in the header. TIMviewer rejects them with a 'not supported' message.

Quote
When scaling up values from lower to higher bit depth, left bit replication is a simple and quick solution.
Thank you for this info optiroc  ;) I'll do some speed testing with these methods when I do my next update. There's an scholarly analysis of the bit-replication method in the PDF HERE.
Even if you happen to be edumacated like me (can count all the way to 20 ifn you take my socks off), there's a simple chart near the end which shows the accuracy of this method compared to ideal.

Squall_FF8

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #12 on: January 01, 2018, 03:18:06 pm »
I checked Irfanview and NeoPain. As far as I can tell, neither saves in 16bit BMP format. Infraview has an option "(24 BPP, simple RGB-565)", but it seems to output 24bit images. Maybe I'm missing something.
Hmm, it seems you are right, sorry for the confusion! I never used it but kind-a expected, if conversation is there, it will try to save in lowest possible (16bit in that case)

Quote
There's an scholarly analysis of the bit-replication method in the PDF HERE.
Even if you happen to be edumacated like me (can count all the way to 20 ifn you take my socks off), there's a simple chart near the end which shows the accuracy of this method compared to ideal.
Sorry if I'm going to ruin your 'dream' for ideal, but here ideal is simple linear interpolation, the same you achieved by x8,22. Once you do 8->5 bit, the 3 bits are gone forever. That's why, when you do the inverse 5->8 regardless what value you choose for the missing 3 bits will be a wild guess. So it doesn't really matter what function you will choose. Is it simple right shift, is it going to be multiplication with a constant, or bit-replication - doesn't matter, your chance for guessing the original value is 1 of 8.

What that mean? If you make converter, just implement whatever is easier/faster for you. If you strive for accuracy - implement at least 2 methods that output different values and then you decide which is better (subjective)
« Last Edit: January 01, 2018, 04:24:24 pm by Squall_FF8 »

weissvulf

  • Sr. Member
  • ****
  • Posts: 324
  • Good news! An anomaly solved the enigma.
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #13 on: January 01, 2018, 05:16:55 pm »
Quote
sorry for the confusion!
I'm extremely grateful to anyone who tries to lend a hand! Even if there's some confusion, I usually learn something new. I view it as nothing less than a 'gift' when people take their time to reply to my questions  :)

Quote
here ideal is simple linear interpolation, the same you achieved by x8,22
Exactly true. I think the only benefit of bit-replication is that it theoretically takes less CPU cycles than 'x8.22 rounded', yet produces the same result most of the time. For example, maybe you could triple your speed in exchange for adding a small 2% error margin. Like you said earlier, speed is probably not a huge issue with converting small images on modern PCs, but I am glad to have the information to check out!

wanzer

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #14 on: January 02, 2018, 05:50:18 am »
I though NeoPaint DOS would do 16-bit color because it offers 16-bit modes, but it seems it only saves to 24-bit.

I had no idea support for 16-bit BMP was so poor. Am I the only person who thinks GIMP is unintuitive? I wonder how difficult it would be to add the functionality to IrfanView, or Paint.NET.... Wikipedia says 16-bit bmp data is raw so maybe it's worth while, I dunno...

And yes I like Front Mission ^_^
« Last Edit: January 02, 2018, 06:22:24 am by wanzer »

weissvulf

  • Sr. Member
  • ****
  • Posts: 324
  • Good news! An anomaly solved the enigma.
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #15 on: January 03, 2018, 04:10:45 pm »
Quote
And yes I like Front Mission ^_^
Giant killer robots + turn based strategy, what's not to like!?  :)
Front Mission 3 Quote of the Day: "If they mean business, they'll get the business end of my wanzer! "

Quote
Am I the only person who thinks GIMP is unintuitive?
No. Most people I've talked to feel the same way. It's still wonderful to have a free pro-level photo editor. Like any program, if you work with it for awhile, you start to get used to the layout.

I think the 16bit format has largely been dropped because there isn't as much need for it. When consoles had 1MB of video RAM, the compact 16bit image offered a large performance boost over 24bit. In these days of 1GB+ video RAM, size is just not as important. Also, modern games seem to rely heavily on lighting effects and I suspect 16bit colors would tend to show color-banding when the lighting is applied under certain conditions (fog etc).

Squall_FF8

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #16 on: February 03, 2018, 02:52:30 pm »
Quote
I used "color x 8.22 rounded", but it is significantly slower.
I was reading a book and suddenly our conversation pop up. The reason for that is 8.22 is actually 255/31, so you may try color x 255 / 31 instead.

P.S. FAST6191 the book I was reading was your hacking 2016 guide. There is mistake on page 68: your suggestion for the 5->8bit is to use 255/32 (with 7.96875 multiplayer), but that will never produce full intensity of 255.

weissvulf

  • Sr. Member
  • ****
  • Posts: 324
  • Good news! An anomaly solved the enigma.
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #17 on: February 06, 2018, 11:50:10 pm »
Neat stuff Squall! I'll add this to my 'speed test' list when I rework the tool and see how it works. I've been working on a crude 'bitmap-font' text writing tool lately, and these tips may come in handy for it also.

I read a bunch of that guide too and learned some things so thanks to FAST6191 too  :thumbsup:

RidFin

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #18 on: February 18, 2018, 05:06:37 pm »
Imagemagick can do that among many other things, I am sure there is some kind of binding for your programming language too.

https://www.imagemagick.org/script/command-line-options.php#depth

weissvulf

  • Sr. Member
  • ****
  • Posts: 324
  • Good news! An anomaly solved the enigma.
    • View Profile
Re: Any good editors that save 16bit BMPs?
« Reply #19 on: February 21, 2018, 07:45:23 pm »
Imagemagick has quite a lot of features - nice!
On a related note, I was recently reminded that TIMviewer includes a 16 <> 24 bit converter for TIMs.