anchor.diff:                      bs.WriteACLum(0, 0)
   
               for d in 1 .. 2 do
  -                bs.WriteDCChrom(block.[0].[d])
  +                bs.WriteDCChrom(block.[0].[d] - lastDC.[d])
                   let mutable leading = 0
                   let mutable i = 1 
                   while i < 64 do
  
positive.code: 
  
          let test() = 
              testBlock
                  |> ycbcr
                  |> dct
                  |> quantify
                  |> zigZag
                  |> List.singleton
                  |> writeImage (V2i(8,8))
  
  
  
      let testscan() =
          let data = Jpeg.test()
          data |> Array.map (sprintf "0x%02X") |> String.concat ";" |> printfn "%s"
          printfn "%A" data.Length
  
          File.writeAllBytes @"C:\Users\Schorsch\Desktop\wtf.jpg" data
  
  
negative.code:                 
                  0.25 * cx * cy * sum
              )
          let hsv2rgb (h : float) (s : float) (v : float) =
              let s = clamp 0.0 1.0 s
              let v = clamp 0.0 1.0 v
  
              let h = h % 1.0
              let h = if h < 0.0 then h + 1.0 else h
              let hi = floor ( h * 6.0 ) |> int
              let f = h * 6.0 - float hi
              let p = v * (1.0 - s)
              let q = v * (1.0 - s * f)
              let t = v * (1.0 - s * ( 1.0 - f ))
              match hi with
                  | 1 -> V3d(q,v,p)
                  | 2 -> V3d(p,v,t)
                  | 3 -> V3d(p,q,v)
                  | 4 -> V3d(t,p,v)
                  | 5 -> V3d(v,p,q)
                  | _ -> V3d(v,t,p)
  
          let imageSize = V2i(1920,1080)
          let testBlocks =
              let blockCount = imageSize / 8
              List.init (blockCount.X * blockCount.Y) (fun bi ->
                  let bx = bi % blockCount.X
                  let by = bi / blockCount.X
  
                  Array.init 64 (fun i ->
                      let x = 8*bx + i%8
                      let y = 8*by + i/8
  
                      let x = x / 18
                      let y = y / 18
  
                      let r = (x + y) % 2
  
  
                      if r > 0 then
                          let h = hsv2rgb ((float x + float y) / 27.0) 1.0 1.0
                          h
                      else
                          V3d(0.4, 0.4, 0.4)
                  )
  
              )
  
  
          let printMat8 (arr : 'a[]) =
              arr |> Array.map (sprintf "%A") |> Array.chunkBySize 8 |> Array.map (String.concat " ") |> String.concat "\r\n"
          
          let QBase =
              [|
                  16;   11;   10;   16;   24;   40;   51;   61;
                  12;   12;   14;   19;   26;   58;   60;   55;
                  14;   13;   16;   24;   40;   57;   69;   56;
                  14;   17;   22;   29;   51;   87;   80;   62;
                  18;   22;   37;   56;   68;  109;  103;   77;
                  24;   35;   55;   64;   81;  104;  113;   92;
                  49;   64;   78;   87;  103;  121;  120;  101;
                  72;   92;   95;   98;  112;  100;  103;   99;
              |]
  
          let Q (q : float) =
              let q = q |> max 1.0 |> min 100.0
              let s = if q < 50.0 then 5000.0 / q else 200.0 - 2.0 * q
              QBase |> Array.map (fun v ->
                  floor ((s * float v + 50.0) / 100.0) |> int  |> max 1
              )
                 
          let quality = 70.0
          let QLum = Q quality
  //            [|
  //                2;  2;  2;  2;  3;  4;  5;  6;
  //                2;  2;  2;  2;  3;  4;  5;  6;
  //                2;  2;  2;  2;  4;  5;  7;  9;
  //                2;  2;  2;  4;  5;  7;  9; 12;
  //                3;  3;  4;  5;  8; 10; 12; 12;
  //                4;  4;  5;  7; 10; 12; 12; 12;
  //                5;  5;  7;  9; 12; 12; 12; 12;
  //                6;  6;  9; 12; 12; 12; 12; 12;
  //            |]
  
          let QChrom = Q quality
  //            [|
  //                 3;  3;  5;  9; 13; 15; 15; 15;
  //                 3;  4;  6; 11; 14; 12; 12; 12;
  //                 5;  6;  9; 14; 12; 12; 12; 12;
  //                 9; 11; 14; 12; 12; 12; 12; 12;
  //                13; 14; 12; 12; 12; 12; 12; 12;
  //                15; 12; 12; 12; 12; 12; 12; 12;
  //                15; 12; 12; 12; 12; 12; 12; 12;
  //                15; 12; 12; 12; 12; 12; 12; 12;
  //            |]
              
  
          let quantify (block : V3d[]) =
              let round (v : V3d) = V3i(int (round v.X), int (round v.Y), int (round v.Z))
              Array.map3 (fun ql qc v -> round(v / V3d(float ql,float qc,float qc))) QLum QChrom block
  
          type TableSpec =
              {
  