Mon, Dec 2, 2:09 AM CST

Renderosity Forums / Poser - OFFICIAL



Welcome to the Poser - OFFICIAL Forum

Forum Coordinators: RedPhantom

Poser - OFFICIAL F.A.Q (Last Updated: 2024 Dec 01 9:20 pm)



Subject: .NET RSR library


Syrus_BD ( ) posted Sat, 17 November 2012 at 5:15 PM · edited Mon, 02 December 2024 at 2:05 AM

Greetings all,

I was wondering if any one knows of any .NET libraries out there that can process/convert .RSR images for old Poser content?

I'm writing an application to automate some of my content importing tasks and I'd like to be able to programatically convert any .rsr files to .png (.NET, C#, VS2012).

I'm aware of the RSR Converter tool for windows (1.0.0.2), but as far as I can tell it's GUI operated only and doesn't provide command line access to its utilities.

Either command line access or a .NET library would work for me.

Can anyone point me in the right direction?

Cheers,

 

~ R


bagginsbill ( ) posted Sat, 17 November 2012 at 5:31 PM · edited Sat, 17 November 2012 at 5:32 PM

In case you get no data, this might prove helpful:

http://www.imagemagick.org/pipermail/magick-users/2005-November/016668.html

I don't read PERL so I don't know WTF it says, but it looks like not a lot of code.

I have used ImageMagick in the (way) past. It's very 90's but still pretty easy to code with.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


Artelis ( ) posted Sat, 17 November 2012 at 6:32 PM

I haven't looked at this much myself, but RSR files are actually ye olde Apple PICT images, they're just missing the header.

If you insert a load of nulls at the beginning of the file, 0xFC bytes in length, it can be processed as a PICT.


Syrus_BD ( ) posted Sat, 17 November 2012 at 8:58 PM · edited Sat, 17 November 2012 at 8:58 PM

Some really good information here. These two posts actually relate to eachother as it looks like the perl script (bagginsbill) is getting image magick to interpret the RSR files as pict files, just as Artelis alluded to.

Thanks so much. At the very least I can do some bitwise operations on the file if need be, instead of requiring the entire imagemagick package.

As always the Renderosity forum comes through for me again :)

 

~ R


Artelis ( ) posted Sat, 17 November 2012 at 9:37 PM

If you wanted to feed it to a console program to have it do the work, you could maybe use XnView (well, its console converter, NConvert).

XnView has an SDK which may help too, but you'd probably need to write your own .NET wrapper for it, I don't know of any.


lmckenzie ( ) posted Sun, 18 November 2012 at 4:44 AM

XFX3D.net (mentioned in the link BB posted) had the best info on this. Unfortunately, it's been dead for a long time - he even had the headers to download.

I got something partially working years ago in VB6. It was basically read the .rsr until the first LF, discard those bytes, write the .pict file consisting of the header followed by the remainder of the .rsr, use imagemagick to convert the .pict to .png.

I actually used GraphicsMagick (http://www.graphicsmagick.org/) which is a fork of ImageMagick. It has a COM dll that worked better with VB for me since I wanted to avoid using a command line. Actually, I usually use the library that Artelis mentions but IIRC, the COM version at least reads but doesn't write .pict format

I say that it worked partially. It successfully converted some .rsr files but not others. The only consistent pattern I could find was that it failed on .rsr files from Japanese sites. Seems like the Japanese version of Poser was doing something different and I was frankly too lazy to try to figure it out since this was just an extra for a Poser database app.

You can find some info on the .pict header here: http://www.fileformat.info/format/macpict/egff.htm

Excerpt from the original page at XFX3D:

"Poser RSR thumbnails are 32-bit QuickDraw PICT2 images with the header swapped out for a special RSR Thumbnail header instead (as most of the meta-information in the PICT header isn't necessary and can be assumed by Poser, like the width of the image which is always 91px, for instance).

As a result, it's pretty easy to convert from PICT to RSR and vice-versa. All you have to do is remove the first 'line' (i.e what a text editor on UNIX would consider a line, the bytes up to and including the first linefeed character, aka "n" to programmers) and replace it with the appropriate header file below."
 ------------------------

The header I came up with was 512 null bytes followed by the data as listed at fileformat.info for a ver. 2 pict (using 72 for orig. h & V res.). All off this was several computers ago and I can't seem to get the GraphicsMacick dll registered on this machine for some reason so I can't test any of it.

EDIT: Try contacting Dizzi here at rendo - created a rsr2png converter (in freestuff here) & may be able to help or maybe do a command line version for you. It's using .NET so a better match than anything I can tell you :-)

"Democracy is a pathetic belief in the collective wisdom of individual ignorance." - H. L. Mencken


hborre ( ) posted Sun, 18 November 2012 at 7:13 AM

IIRC, Dimension3D also has a standalone program for converting RSR to PNG in one of his tool collections.


bagoas ( ) posted Sun, 18 November 2012 at 9:56 AM

The converter in P3dO works fine but works only on the current foldernand not on sub-folders. You can not use it to update a whole Runtime in one go. 


lmckenzie ( ) posted Mon, 19 November 2012 at 7:07 AM

"You can not use it to update a whole Runtime in one go. "

The Pro version supposedly does this. The free version is limited to a single folder at a time.

Worst case, you could try launching something like Dizzi's converter from your application and then controlling it. I've done that as an alternative when there was no API or command line option. I know how to do it using Win32 API calls, .NET probably has an easier way to accomplish the same thing.  

* *

"Democracy is a pathetic belief in the collective wisdom of individual ignorance." - H. L. Mencken


Syrus_BD ( ) posted Mon, 19 November 2012 at 8:45 AM

Thank you all for your input. I finally found a reason to use my hex editor after reading up on PICT header formats and attempting bit operations in code. No luck though, but interesting enough as a hobby project :)

Still rsr conversion is a minor item being the extreme exception and not the rule; I'm going to log the archives that have RSR thumbnails with no matching PNG's and then use my original GUI RSR program to convert them as a manual step then reprocess the extracted archives.

I did send Dizzi an IM so I'll wait to see if I get a response.

My first go at the null header block didn't work, so from a programatic point of view that's the direction I'll keep experimenting with for now. I just need a better understanding of the PICT header at the byte level.

Just as an FYI for all those who also helped with my last thread, this is a tangential project  to the Cloud Rendering thread I posted a while back (I'm still working on it! lol).

 

~ R


lmckenzie ( ) posted Wed, 21 November 2012 at 5:20 AM

Content Advisory! This message contains nudity

file_488744.jpg

After messing with this some more, I got something that to work a bit better - a different .pct header and finding out more about the .rsr files I have. I was able to convert about 500 .rsr files OK. The caveat is that most only show up in my image viewer if I turn off or delete the alpha channel, then they're fine. I don't remember having this issue before but then I was converting to .png. Since I can't get GraphicsMagick running, I'm just saving and viewing the .pct files. I don't really need the alpha transparency for my archive database thumbnails anyway but hopefully I can figure it out in any case.

Most .rsr files (mine anyway) have a LF (hex 0A) at byte 303 (i.e. 'Normal'). Some have the LF a few bytes past 303 (i.e. 'Moved LF'). Some have what looks like some sort of embedded color profile in the header starting at byte 301. These have a block that includes text like "sRGB IEC1966-2.1" and "Hewlett-Packard" (i.e. Profile). Some, possibly all with a color profile were of Japanese origin. 

Note: a lot of my .rsr files were converted from .pngs with P3DO for P4, but I think at least some originals were in the batch I tested.

The image X & Y sizes 91 (hex 5B) appears in at least two places, including in the 8 bytes following the LF in Normal and Moved LF files. The sizes in some files were not 91 in this section for some reason and caused errors in my image viewer To work around this, I added the proper 8 bytes to the end of my stock header file.

My quick and very ugly process is:
A. read the stock header into a byte array
B. read 303 bytes from the .rsr file into a byte array
--
If byte 301 is 161 (hex A1), it has a color profile (don't know if this is always true)
read the remainder of the file into a byte array then jump to writing the .pct
or
If byte 303 is LF, read 8 more bytes to account for the longer stock header (i.e. move the file pointer).
read the remainder of the file into a byte array.
or
If 303 is not LF read bytes until LF is found or bail after (arbitrary) 100 bytes.
If found, read 8 more bytes to account for the longer stock header. (i.e. move the file pointer).
read the remainder of the file into a byte array then jump to writing the .pct
--
Write out the .pct file consisting of the stock header array followed by the remainder array

The logic & structure sucks, and there are a couple of kludges in the code not listed but it 'evolved' as I found things and it appears to mostly work so I'll "refactor" it later. I can send you a copy if you promise not to laugh, but I'm sure you can come up with something better.

"Democracy is a pathetic belief in the collective wisdom of individual ignorance." - H. L. Mencken


lmckenzie ( ) posted Wed, 21 November 2012 at 5:25 AM

This is my stock .pct header. My hex editor XVI32 allows pasting text as a 'hex string'so I could copy & paste this text (should be one long line) to a new file and save it as binary to incorporate in .pct files. If you want a binary version, let me know - maybe your editor doesn't like spaces between bytes. 

Following the 512 null bytes is the file size (in this case 17 64 Or 5,988). It seems not to be significant - (Apple says not to use it to get the file size). It appears to be the size as shown in Windows properties minus 512. Using the same value for all files hasn't caused problens yet so it doesn't appear to be necessary to calculate it for each different file. I've even used 00 00 and it still works.

fileformat.info says that the bytes after the opcode (0C 00) can be FF EF or FF EE. That seems to be a typo or I misread it. All of the .rsr files I have use FF FE.

The 8 bytes following 0A are the extra I mentioned above. In some .rsr files the 00 5B 00 5B (i.e. 91 x 91) dimensions were values like 600 x 600 for some reason so I read past them (and tacked the proper bytes onto the stock header).

All of this is largely pure guesswork & speculation. 99.9% of the stuff I do is blessedly ASCII :-)


00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 64 00 00 00 00 00 5B 00 5B 00 11 02 FF 0C 00 FF FE 00 00 00 48 00 00 00 48 00 00 00 00 00 00 00 5B 00 5B 00 00 00 00 00 01 00 0A 00 00 00 00 00 5B 00 5B  

 

"Democracy is a pathetic belief in the collective wisdom of individual ignorance." - H. L. Mencken


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.