/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#ifndef UshortGray_h_Included
#define UshortGray_h_Included
#include "IntDcm.h"
/*
* This file contains macro and type definitions used by the macros in
* LoopMacros.h to manipulate a surface of type "UshortGray".
*/
/*
* Note: The following (original) equation was incorrect:
* gray = (((19595*r) + (38470*g) + (7471*b) + 32768) / 65536);
*
* The new component coefficients were derived from the following equation:
* k*rf*255 + k*gf*255 + k*bf*255 = 2^24 - 1
*
* The new calculated coefficients are:
* rf = 19672
* gf = 38620
* bf = 7500
*
* Thus the new equation would be:
* gray = (((19672*r) + (38620*g) + (7500*b) + 128) / 255)
* but it has been tweaked so the faster "divide by 256" can be performed and
* the "add 128" can be removed. Therefore, the resultant formula is optimal:
* gray = (((19672*r) + (38621*g) + (7500*b)) / 256)
*/
#define ComposeUshortGrayFrom3ByteRgb(r, g, b) \
do { \
int r, g, b; \
ExtractIntDcmComponentsX123(rgb, r, g, b); \
(pixel) = ComposeUshortGrayFrom3ByteRgb(r, g, b); \
} while (0)
do { \
} while (0)
do { \
} while (0)
((r) = (g) = (b) = ((pRas)[x] >> 8))
do { \
(a) = 0xff; \
} while (0)
do { \
int r, g, b; \
ExtractIntDcmComponentsX123(rgb, r, g, b); \
} while (0)
(pRas)[x] = ComposeUshortGrayFrom3ByteRgb(r, g, b)
COMP_PREFIX ## A = 0xffff
COMP_PREFIX ## G = (pRas)[0]
#define UshortGrayIsPremultiplied 0
PREFIX = 0
#endif /* UshortGray_h_Included */