In my project I need to open the SEQ file, so I use FileInputStream, it requires to load data to byte array. But because of that each pixels get wrong value (cause they are Integers). 

Below in my code you can see that i put pixels in 2d array and for that I count each value of pixel, in line:

```
 wart =(int) (buf[offset]) +(int)(buf[offset+1]) * 255;

```

I know that values because of byte input format are wrong (first two pixels aka double should be `152,109692453756 and 152,068644316116` but in my Java function they get -`2474, -690`)

I tried using the mask:

```
wart =(int) (buf[offset]<< 8) & 0x0000ff00 +(int)(buf[offset+1])& 0x000000ff * 255  ;

```

it helps a little (values arent negative, but they are "shifted" too much (first two pixels `19456, 18944`)
I don't know how to solve this problem. I know that the mask should be different, but I don't know how to set it.

```
    public class Sekwencja2 {
    @SuppressWarnings("empty-statement")
    public double[] sekwencja2(String nazwa,int nr_klatki) throws FileNotFoundException, IOException{            
                        InputStream is = null;
                        DataInputStream dis = null;                           
                        is = new FileInputStream(nazwa);
                        dis = new DataInputStream(is);                            
                        int length = dis.available();
                        byte[] buf = new byte[length];                           
                        dis.readFully(buf);                            
                        int l_klatek = ((length-158864)/158864)+1;                            
                        int width = 320;
                        int height = 240;
                        int C1=21764040;
                        double C2=3033.3;
                        double C3=134.06;
                        int z = 0;
                        double[] oneDArray = new double[width*height];                            
                        double [][] pixels = new double[width][height];                       

                        int offset =0;
                        char type;
                        String typeText;
                        type=(char)buf[0];
                        typeText =Character.toString(type);
                        switch (typeText) {
                            case "A":
                            if(nr_klatki == 1)
                            offset= 696;
                            else 
                            offset = 158136+(nr_klatki-1)*569+(nr_klatki-2)*(320*240*2+3839);
                            break;
                            case "F":
                            offset=(nr_klatki-1)*158864 + 1373;
                            break;
                            }                          

                        int wart = 0 ;                            
                        for(int x = 0; x<320; x++){
                         for (int y = 0; y<240;y++){
                             switch (typeText){
                                 case "A":
                                     if(nr_klatki==1)
                                         wart =(int) (buf[offset]) +(int)(buf[offset+1]) * 255;
                                     else
                                         wart = (int)(buf[offset]<< 8)& 0x0000ff00 +(int)(buf[offset+1])&0xff*255   ;
                                     break;
                                 case "F":
                                     wart = (buf[offset]<< 8)& 0x0000ff00  +(buf[offset+1])& 0x000000ff * 255  ;
                                     break;
                             }

                              System.out.print(", "+wart);

                               pixels[x][y]=wart;
                                 offset = offset+2;                                      
                         }
                        }
                        for(int i = 0; i < width; i ++)
                                {
                            System.arraycopy(pixels[i], 0, oneDArray, i * height, height);
                                }                       

        return oneDArray;
    }
}

```

I know it's a mess, a lot of things are commented :)