Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 4 5 6 [7] 8 9 10 ... 50   Go Down

Author Topic: msh Binary format  (Read 109365 times)

0 Members and 10 Guests are viewing this topic.

shardana

  • member
  • Offline Offline
  • Posts: 850
Re: msh Binary format
« Reply #72 on: April 15, 2014, 02:09:15 PM »

Thanks Benitomuso!
Logged

hello

  • member
  • Offline Offline
  • Posts: 287
  • aka Aufpassen! aka Alfie!
Re: msh Binary format
« Reply #73 on: April 17, 2014, 10:06:54 AM »


The four modes are the same as the four modes in png, just with a few minor differences I am trying to figure out why I have glitches.


Did you manage to figure out what causes these glitches? Doesn't look like a simple problem...
Logged

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1534
Re: msh Binary format
« Reply #74 on: April 17, 2014, 10:55:38 AM »

I have 23 images in this format, my code loads 22 of them perfectly. One has a glitch.

It seems to be an initial value problem.  When you start a new line of the graphic, some modes seem to expect the first pixel to be set to zero, some seem to expect it to be set to the same value as the pixel above.

It makes no sense at all

Code: [Select]
                for (int y = 0; y < height; y++)
                {
                    if (mode[y] < 4)
                    {
                        r = g = b = 0;
                    }
                    for (int x = 0; x < width; x++)
                    {
                        #region Decode
                        switch (mode[y])
                        {
                            // none
                            case 0:
                                r = br.ReadByte();
                                g = br.ReadByte();
                                b = br.ReadByte();
                                a = 255;
                                break;

                            // sub
                            case 1:
                                r += br.ReadByte();
                                g += br.ReadByte();
                                b += br.ReadByte();
                                a = 255;
                                break;

                            // up
                            case 2:
                                b = data[pos - prev];
                                g = data[pos - prev + 1];
                                r = data[pos - prev + 2];

                                r += br.ReadByte();
                                g += br.ReadByte();
                                b += br.ReadByte();
                                a = 255;
                                break;

                            // average
                            case 3:                             
                                r = Average(r, data[pos - prev + 2]);
                                g = Average(g, data[pos - prev + 1]);
                                b = Average(b, data[pos - prev]);
                               
                                r += br.ReadByte();
                                g += br.ReadByte();
                                b += br.ReadByte();
                                a = 255;
                                break;

                            // paeth
                            case 4:
                                if (pos < prev + 4)
                                {                                   
                                    r = (byte)paethPredictor(r, data[pos - prev + 2], 0);
                                    g = (byte)paethPredictor(g, data[pos - prev + 1], 0);
                                    b = (byte)paethPredictor(b, data[pos - prev], 0);                                   
                                }
                                else
                                {
                                    if (x > 0)
                                    {
                                        r = (byte)paethPredictor(r, data[pos - prev + 2], data[pos - prev - 2]);
                                        g = (byte)paethPredictor(g, data[pos - prev + 1], data[pos - prev - 3]);
                                        b = (byte)paethPredictor(b, data[pos - prev], data[pos - prev - 4]);
                                    }
                                    else
                                    {
                                        r = (byte)paethPredictor(data[pos - prev + 2], data[pos - prev + 2], data[pos - prev - 2]);
                                        g = (byte)paethPredictor(data[pos - prev + 1], data[pos - prev + 1], data[pos - prev - 3]);
                                        b = (byte)paethPredictor(data[pos - prev],     data[pos - prev],     data[pos - prev - 4]);
                                    }
                                }
                                r += br.ReadByte();
                                g += br.ReadByte();
                                b += br.ReadByte();
                                a = 255;
                                break;

                        }
                        #endregion

                        data[pos++] = b;
                        data[pos++] = g;
                        data[pos++] = r;
                        data[pos++] = a;

                    }
                }

Two images of my test app, the left window is the RGB texture, middle the alpha mask, right the combination.



And here is the one graphic with a glitch

Logged

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1534
Re: msh Binary format
« Reply #75 on: April 18, 2014, 12:05:33 AM »

sorted



This code makes me think the developer was either mad, or bordering on genius.

It's basically all the front end filtering that PNG does, but without the compression. So you end up with a file that is bigger than a standard tga file, but will compress better if zipped up.

So I guess it must be compressed in the install package, which makes all the encoding worthwhile.
Logged

hello

  • member
  • Offline Offline
  • Posts: 287
  • aka Aufpassen! aka Alfie!
Re: msh Binary format
« Reply #76 on: April 18, 2014, 02:16:42 AM »

Great! Impressive progress! Does this mean you can also write the image format? The format makes sense for the sfs files that contain all the ingame textures.
Logged

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23875
  • Taking a timeout
    • STFU
Re: msh Binary format
« Reply #77 on: April 18, 2014, 02:50:40 AM »

Actually the game does read uncompressed TGA files too, so I'm wondering what might be the reason to re-invent the wheel for the developer?
As much as I see it, an uncompressed TGA compresses just as good as IMF files do, it usually even ends up to be a few bytes smaller.

Best regards - Mike
Logged
Don't split your mentality without thinking twice.

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1534
Re: msh Binary format
« Reply #78 on: April 18, 2014, 08:49:57 AM »

Yes you are correct, this format is useless to modders. However some of the standard textures are in this format so I do need to be able to read it.
Logged

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1534
Re: msh Binary format
« Reply #79 on: April 19, 2014, 10:13:41 AM »

I've added a texture browser dialog. At the moment it just lets you invert an image.

I have to invert textures a lot, not sure why but they always seem to be upside down for me.

I can add other functionality later if required

Can someone tell me why all the mods I look at have holes in the textures? Looks like they have been attacked by moths.
Logged

SAS~Malone

  • flying as #46 with the FAC
  • Editor
  • member
  • Offline Offline
  • Posts: 14562
  • proud member of that 'other' site
Re: msh Binary format
« Reply #80 on: April 20, 2014, 02:48:10 AM »

sounds like the damage textures are showing, maybe?
also being a coding noob, i can't offer any real advice, but i'm very impressed with the work you are doing - keep it up! :D
Logged
.....taking fun seriously since 1968.....  8)

hello

  • member
  • Offline Offline
  • Posts: 287
  • aka Aufpassen! aka Alfie!
Re: msh Binary format
« Reply #81 on: April 23, 2014, 03:07:12 AM »

sounds like the damage textures are showing, maybe?
Yes,very likely. Any progress? Can't wait to try this tool myself.
Logged

benitomuso

  • SAS Team
  • member
  • Offline Offline
  • Posts: 2587
  • P.A.L.
Re: msh Binary format
« Reply #82 on: April 23, 2014, 04:48:43 AM »

+1
Logged

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1534
Re: msh Binary format
« Reply #83 on: April 23, 2014, 07:05:16 AM »

I've been earning money the last few days, sorry  :)

I have just finished the job and will have a couple of days free to do some more.

Whatever state it is in on Sunday, I will publish it so you guys can start playing with it and come up with bug reports and feature requests.

It is not finished, it's probably going to crash a lot, but I'll keep working on it when I get chance.
Logged
Pages: 1 ... 4 5 6 [7] 8 9 10 ... 50   Go Up
 

Page created in 0.031 seconds with 25 queries.