Extend NConvert with a custom format
Moderators: XnTriq, helmut, xnview
-
- Posts: 11
- Joined: Mon May 30, 2016 3:42 pm
Extend NConvert with a custom format
Hello,
I'd like to add support for a RAW format (which really only includes raw data) used by WorldMachine and Unity for heightmaps.
The format is very simple fortunately, it is the plain 8-Bit, 16-Bit or even 32-Bit data written out as binary.The filesize alone can be used to calculate the exact size and bit depth. Useful parameters would be per-row/per-column write order, horizontal/vertical flip, bit depth, byte order, etc.
Is it possible to add such a simple custom format to NConvert without creating a 'wrapper'? Or, are you willing to implement this for me (and the whole Unity community )?
It has been a problem for all terrain users in Unity to convert to this not-so-widely-used format, which do not own photoshop, for a long time...
Thanks for you help!
Seneral
I'd like to add support for a RAW format (which really only includes raw data) used by WorldMachine and Unity for heightmaps.
The format is very simple fortunately, it is the plain 8-Bit, 16-Bit or even 32-Bit data written out as binary.The filesize alone can be used to calculate the exact size and bit depth. Useful parameters would be per-row/per-column write order, horizontal/vertical flip, bit depth, byte order, etc.
Is it possible to add such a simple custom format to NConvert without creating a 'wrapper'? Or, are you willing to implement this for me (and the whole Unity community )?
It has been a problem for all terrain users in Unity to convert to this not-so-widely-used format, which do not own photoshop, for a long time...
Thanks for you help!
Seneral
-
- Posts: 11
- Joined: Mon May 30, 2016 3:42 pm
Re: Extend NConvert with a custom format
For reference, here is a simple 512x512 16-Bit .raw perlin composition:)
-
- Author of XnView
- Posts: 45068
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France
Re: Extend NConvert with a custom format
your sample has not a file size of 512x512x2bytes?Seneral wrote:For reference, here is a simple 512x512 16-Bit .raw perlin composition:)
Pierre.
-
- Posts: 11
- Joined: Mon May 30, 2016 3:42 pm
Re: Extend NConvert with a custom format
Good point, but I'm confused now. I did not work with the file format as closely in my tools yet, I'll ask a developer which has used it in it's tools. I hope to give a detailed explanation on whats going on this evening:)xnview wrote:your sample has not a file size of 512x512x2bytes?
-
- Posts: 11
- Joined: Mon May 30, 2016 3:42 pm
Re: Extend NConvert with a custom format
Ok, the specification actually is correct. But, windows and some other operating system treat kilobytes as 1024 bytes rather than 1000 (see wikipedia) so if you see exactly 512kB, here is what happens:xnview wrote:your sample has not a file size of 512x512x2bytes?Seneral wrote:For reference, here is a simple 512x512 16-Bit .raw perlin composition:)
512*512 * 2Bytes = 524.288 Bytes => 524.288 Bytes / 1024 = 512kb
for operating systems using 1000Bytes/kB it's then obviously roughly 524kB.
So the specification mentioned above is correct:)
-
- Author of XnView
- Posts: 45068
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France
Re: Extend NConvert with a custom format
houps the download was not goodSeneral wrote:Ok, the specification actually is correct. But, windows and some other operating system treat kilobytes as 1024 bytes rather than 1000 (see wikipedia) so if you see exactly 512kB, here is what happens:xnview wrote:your sample has not a file size of 512x512x2bytes?Seneral wrote:For reference, here is a simple 512x512 16-Bit .raw perlin composition:)
512*512 * 2Bytes = 524.288 Bytes => 524.288 Bytes / 1024 = 512kb
for operating systems using 1000Bytes/kB it's then obviously roughly 524kB.
So the specification mentioned above is correct:)
So you can import RAW file, but currently only 8bits
Pierre.
-
- Posts: 11
- Joined: Mon May 30, 2016 3:42 pm
Re: Extend NConvert with a custom format
You mean, in the software I'm using?xnview wrote:houps the download was not good
So you can import RAW file, but currently only 8bits
No, raw is a fully featured file format in Unity and we can use it fine - but other common formats like png are only supported in 8Bit...
So we would need a converter to convert to 16Bit raw for some special cases like heightmaps - the terrain system uses this format natively, aswell as a tool that I'm using, TC. But without Photoshop we have no way to convert to that format. I hope that makes it clear why we really need a converter, and as I was using NConvert before I thought it would be a great idea to have it integrated, depending on how much it would take in terms of work.
So, I hope the download is now working for you, but anyway it's not too complex as I said;)
I'd appreciate any good news in that regard:)
Seneral
EDIT: I think I misunderstood your post, so does this mean NConvert already supports Raw? I tried it already, but it failed, maybe because as you said it was 16Bit. Is there any chance you'll add 16 bit support and possibly some parameters regarding read behaviour?
Because 16Bit is the real reason behind using the raw format for me and the Unity community;)
-
- Author of XnView
- Posts: 45068
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France
Re: Extend NConvert with a custom format
yes NConvert support raw file but only 8bits
Code: Select all
-corder ... -ctype .... -size ...
Pierre.
-
- Posts: 11
- Joined: Mon May 30, 2016 3:42 pm
Re: Extend NConvert with a custom format
Ok, cool, any chance you're going to support 16Bit? Because as I said, that's the only real advantage for Unity users over any other file type;)xnview wrote:yes NConvert support raw file but only 8bitsCode: Select all
-corder ... -ctype .... -size ...
-
- Author of XnView
- Posts: 45068
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France
-
- Posts: 11
- Joined: Mon May 30, 2016 3:42 pm
Re: Extend NConvert with a custom format
Preferrably both, but for my use case only write. Reading is actually very simple, there is even an API call for this in Unity. But reading is really important for Unity in general (terrain exports only to 16Bit raw, so to use it we'd need read, too), but for my specific use case it's only write.xnview wrote:in reading or writting?
The thing preventing of handling all this ourselves in Unity is it's lack of support for other 16Bit formats than raw, so we need a conversion tool, else we'd need loads of third party libraries to account for all possible conversion formats... but this is what NConvert is basically already doing so that's why I'm here;)
If there's any chance you could implement this, I'd very much appreciate it:)
-
- Posts: 11
- Joined: Mon May 30, 2016 3:42 pm
Re: Extend NConvert with a custom format
sry - just realized it was a double post
-
- Author of XnView
- Posts: 45068
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France
Re: Extend NConvert with a custom format
what do you have as source? A 16bits image?Seneral wrote:Preferrably both, but for my use case only write. Reading is actually very simple, there is even an API call for this in Unity. But reading is really important for Unity in general (terrain exports only to 16Bit raw, so to use it we'd need read, too), but for my specific use case it's only write.xnview wrote:in reading or writting?
The thing preventing of handling all this ourselves in Unity is it's lack of support for other 16Bit formats than raw, so we need a conversion tool, else we'd need loads of third party libraries to account for all possible conversion formats... but this is what NConvert is basically already doing so that's why I'm here;)
If there's any chance you could implement this, I'd very much appreciate it:)
Pierre.
-
- Posts: 11
- Joined: Mon May 30, 2016 3:42 pm
Re: Extend NConvert with a custom format
Up to 32Bits, though most are 16-24-Bit PNGs. I'm pretty sure NConvert does support them already, so whats missing is only the raw option, because I thought NConvert has an internal format that the converter converts to and from there is able to convert to any output format, right? So it shouldn't matter...xnview wrote:what do you have as source? A 16bits image?
-
- Author of XnView
- Posts: 45068
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France
Re: Extend NConvert with a custom format
sorry but i means 8 or 16bits per component as reading? source is grey 8bits/component and destination is 16bits/component??
Pierre.