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