2 * Imagesqueeze - Image codec. Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public License
6 * or later as published by the Free Software Foundation.
9 package eu.svjatoslav.imagesqueeze.codec;
12 * Helper class to convert between RGB and YUV
24 public void RGB2YUV() {
26 y = (int) ((r * 0.299000) + (g * 0.587000) + (b * 0.114000));
27 u = (int) ((r * -0.168736) + (g * -0.331264) + (b * 0.500000) + 128);
28 v = (int) ((r * 0.500000) + (g * -0.418688) + (b * -0.081312) + 128);
46 public void YUV2RGB() {
48 b = (int) (y + (1.4075 * (v - 128)));
49 g = (int) (y - (0.3455 * (u - 128)) - (0.7169 * (v - 128)));
50 r = (int) (y + (1.7790 * (u - 128)));