0N/A/*
2362N/A * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#ifndef UshortGray_h_Included
0N/A#define UshortGray_h_Included
0N/A
0N/A#include "IntDcm.h"
0N/A
0N/A/*
0N/A * This file contains macro and type definitions used by the macros in
0N/A * LoopMacros.h to manipulate a surface of type "UshortGray".
0N/A */
0N/A
0N/Atypedef jushort UshortGrayPixelType;
0N/Atypedef jushort UshortGrayDataType;
0N/A
300N/A#define UshortGrayIsOpaque 1
300N/A
0N/A#define UshortGrayPixelStride 2
0N/A#define UshortGrayBitsPerPixel 16
0N/A
0N/A#define DeclareUshortGrayLoadVars(PREFIX)
0N/A#define DeclareUshortGrayStoreVars(PREFIX)
0N/A#define SetUshortGrayStoreVarsYPos(PREFIX, pRasInfo, y)
0N/A#define SetUshortGrayStoreVarsXPos(PREFIX, pRasInfo, x)
0N/A#define InitUshortGrayLoadVars(PREFIX, pRasInfo)
0N/A#define InitUshortGrayStoreVarsY(PREFIX, pRasInfo)
0N/A#define InitUshortGrayStoreVarsX(PREFIX, pRasInfo)
0N/A#define NextUshortGrayStoreVarsX(PREFIX)
0N/A#define NextUshortGrayStoreVarsY(PREFIX)
0N/A#define DeclareUshortGrayPixelData(PREFIX)
0N/A#define ExtractUshortGrayPixelData(PIXEL, PREFIX)
0N/A
0N/A#define UshortGrayXparLutEntry -1
0N/A#define UshortGrayIsXparLutEntry(pix) (pix < 0)
0N/A#define StoreUshortGrayNonXparFromArgb StoreUshortGrayFrom1IntArgb
0N/A
0N/A
0N/A/*
0N/A * Note: The following (original) equation was incorrect:
0N/A * gray = (((19595*r) + (38470*g) + (7471*b) + 32768) / 65536);
0N/A *
0N/A * The new component coefficients were derived from the following equation:
0N/A * k*rf*255 + k*gf*255 + k*bf*255 = 2^24 - 1
0N/A *
0N/A * The new calculated coefficients are:
0N/A * rf = 19672
0N/A * gf = 38620
0N/A * bf = 7500
0N/A *
0N/A * Thus the new equation would be:
0N/A * gray = (((19672*r) + (38620*g) + (7500*b) + 128) / 255)
0N/A * but it has been tweaked so the faster "divide by 256" can be performed and
0N/A * the "add 128" can be removed. Therefore, the resultant formula is optimal:
0N/A * gray = (((19672*r) + (38621*g) + (7500*b)) / 256)
0N/A */
0N/A#define ComposeUshortGrayFrom3ByteRgb(r, g, b) \
0N/A (UshortGrayPixelType)(((19672*(r)) + (38621*(g)) + (7500*(b))) / 256)
0N/A
0N/A#define UshortGrayPixelFromArgb(pixel, rgb, pRasInfo) \
0N/A do { \
0N/A int r, g, b; \
0N/A ExtractIntDcmComponentsX123(rgb, r, g, b); \
0N/A (pixel) = ComposeUshortGrayFrom3ByteRgb(r, g, b); \
0N/A } while (0)
0N/A
0N/A#define StoreUshortGrayPixel(pRas, x, pixel) \
0N/A ((pRas)[x] = (jushort) (pixel))
0N/A
0N/A#define StoreUshortGrayPixelData(pPix, x, pixel, PREFIX) \
0N/A StoreUshortGrayPixel(pPix, x, pixel)
0N/A
0N/A
0N/A#define LoadUshortGrayTo1IntRgb(pRas, PREFIX, x, rgb) \
0N/A do { \
0N/A int gray = (pRas)[x] >> 8; \
0N/A (rgb) = (((gray << 8) | gray) << 8) | gray; \
0N/A } while (0)
0N/A
0N/A#define LoadUshortGrayTo1IntArgb(pRas, PREFIX, x, argb) \
0N/A do { \
0N/A int gray = (pRas)[x] >> 8; \
0N/A (argb) = (((((0xff << 8) | gray) << 8) | gray) << 8) | gray; \
0N/A } while (0)
0N/A
0N/A#define LoadUshortGrayTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
0N/A ((r) = (g) = (b) = ((pRas)[x] >> 8))
0N/A
0N/A#define LoadUshortGrayTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
0N/A do { \
0N/A LoadUshortGrayTo3ByteRgb(pRas, PREFIX, x, r, g, b); \
0N/A (a) = 0xff; \
0N/A } while (0)
0N/A
0N/A#define LoadUshortGrayTo1ByteGray(pRas, PREFIX, x, gray) \
0N/A (gray) = ((pRas)[x] >> 8)
0N/A
0N/A#define LoadUshortGrayTo1ShortGray(pRas, PREFIX, x, gray) \
0N/A (gray) = (pRas)[x]
0N/A
0N/A#define StoreUshortGrayFrom1IntRgb(pRas, PREFIX, x, rgb) \
0N/A do { \
0N/A int r, g, b; \
0N/A ExtractIntDcmComponentsX123(rgb, r, g, b); \
0N/A StoreUshortGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \
0N/A } while (0)
0N/A
0N/A#define StoreUshortGrayFrom1IntArgb(pRas, PREFIX, x, argb) \
0N/A StoreUshortGrayFrom1IntRgb(pRas, PREFIX, x, argb)
0N/A
0N/A#define StoreUshortGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
0N/A (pRas)[x] = ComposeUshortGrayFrom3ByteRgb(r, g, b)
0N/A
0N/A#define StoreUshortGrayFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
0N/A StoreUshortGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
0N/A
0N/A#define StoreUshortGrayFrom1ByteGray(pRas, PREFIX, x, gray) \
0N/A (pRas)[x] = (jushort) (((gray) << 8) + (gray))
0N/A
0N/A#define StoreUshortGrayFrom1ShortGray(pRas, PREFIX, x, gray) \
0N/A StoreUshortGrayPixel(pRas, x, gray)
0N/A
0N/A
0N/A#define DeclareUshortGrayAlphaLoadData(PREFIX)
0N/A#define InitUshortGrayAlphaLoadData(PREFIX, pRasInfo)
0N/A
0N/A#define LoadAlphaFromUshortGrayFor1ShortGray(pRas, PREFIX, COMP_PREFIX) \
0N/A COMP_PREFIX ## A = 0xffff
0N/A
0N/A#define Postload1ShortGrayFromUshortGray(pRas, PREFIX, COMP_PREFIX) \
0N/A COMP_PREFIX ## G = (pRas)[0]
0N/A
0N/A
0N/A#define UshortGrayIsPremultiplied 0
0N/A
0N/A#define DeclareUshortGrayBlendFillVars(PREFIX) \
0N/A jushort PREFIX;
0N/A
0N/A#define ClearUshortGrayBlendFillVars(PREFIX, argb) \
0N/A PREFIX = 0
0N/A
0N/A#define InitUshortGrayBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \
0N/A PREFIX = (jushort) COMP_PREFIX ## G
0N/A
0N/A#define InitUshortGrayBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)
0N/A
0N/A#define StoreUshortGrayBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \
0N/A (pRas)[x] = PREFIX
0N/A
0N/A#define StoreUshortGrayFrom1ShortGrayComps(pRas, PREFIX, x, COMP_PREFIX) \
0N/A StoreUshortGrayPixel(pRas, x, COMP_PREFIX ## G)
0N/A
0N/A#endif /* UshortGray_h_Included */