< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_Palette.h

Print this page


   1 /*
   2  * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  32 
  33 #define GS_NOTGRAY      0       // screen is not grayscale
  34 #define GS_INDEXGRAY    1       // screen is 8-bit indexed with several
  35                                 //  gray colormap entries
  36 #define GS_STATICGRAY   2       // screen is 8-bit with 256 gray values
  37                                 // from 0 to 255 (no index table used)
  38 #define GS_NONLINGRAY   3       /* screen is 8-bit with 256 gray values
  39                                    in non-monotonic order */
  40 
  41 class AwtWin32GraphicsDevice;
  42 
  43 class AwtPalette {
  44 
  45 public:
  46     HPALETTE                Select(HDC hDC);
  47 
  48     void                    Realize(HDC hDC);
  49 
  50     HPALETTE                GetPalette() { return logicalPalette; }
  51 
  52     static void             DisableCustomPalette();
  53 
  54     static BOOL             UseCustomPalette();
  55 
  56                             AwtPalette(AwtWin32GraphicsDevice *device);
  57 
  58     static int              FetchPaletteEntries(HDC hDC, PALETTEENTRY* pPalEntries);
  59     int                     GetGSType(PALETTEENTRY* pPalEntries);
  60 
  61     BOOL                    Update();
  62     void                    UpdateLogical();
  63 
  64     unsigned int            *GetSystemEntries() {return systemEntries; }
  65     unsigned int            *GetLogicalEntries() {return logicalEntries; }
  66     unsigned char           *GetSystemInverseLUT() { return systemInverseLUT; }
  67 
  68 private:
  69     static BOOL             m_useCustomPalette;
  70 
  71     unsigned int            logicalEntries[256];
  72     unsigned int            systemEntries[256];
  73     PALETTEENTRY            systemEntriesWin32[256];  // cached to eliminate
  74                                               // copying it when unnec.
  75     int                     numSystemEntries;
  76     HPALETTE                logicalPalette;
  77 
  78     AwtWin32GraphicsDevice  *device;
  79     unsigned char           *systemInverseLUT;
  80 
  81     /**
  82      * This custom palette is derived from the IE palette.
  83      * Previously, we used a custom palette that used a patented
  84      * algorithm for getting an evently distributed color space.
  85      * But given the realites of desktop and web graphics, it seems
  86      * more important to use a more standard palette, especially one
  87      * that agrees with the predominant browser.  The browser uses
  88      * a slightly modified 6x6x6 colorcube plus a gray ramp plus a
  89      * few other colors.  We still flash with Netscape, but we end
  90      * up using a very similar palette (Netscape uses a 6x6x6 color
   1 /*
   2  * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  32 
  33 #define GS_NOTGRAY      0       // screen is not grayscale
  34 #define GS_INDEXGRAY    1       // screen is 8-bit indexed with several
  35                                 //  gray colormap entries
  36 #define GS_STATICGRAY   2       // screen is 8-bit with 256 gray values
  37                                 // from 0 to 255 (no index table used)
  38 #define GS_NONLINGRAY   3       /* screen is 8-bit with 256 gray values
  39                                    in non-monotonic order */
  40 
  41 class AwtWin32GraphicsDevice;
  42 
  43 class AwtPalette {
  44 
  45 public:
  46     HPALETTE                Select(HDC hDC);
  47 
  48     void                    Realize(HDC hDC);
  49 
  50     HPALETTE                GetPalette() { return logicalPalette; }
  51 




  52                             AwtPalette(AwtWin32GraphicsDevice *device);
  53 
  54     static int              FetchPaletteEntries(HDC hDC, PALETTEENTRY* pPalEntries);
  55     int                     GetGSType(PALETTEENTRY* pPalEntries);
  56 
  57     BOOL                    Update();
  58     void                    UpdateLogical();
  59 
  60     unsigned int            *GetSystemEntries() {return systemEntries; }
  61     unsigned int            *GetLogicalEntries() {return logicalEntries; }
  62     unsigned char           *GetSystemInverseLUT() { return systemInverseLUT; }
  63 
  64 private:


  65     unsigned int            logicalEntries[256];
  66     unsigned int            systemEntries[256];
  67     PALETTEENTRY            systemEntriesWin32[256];  // cached to eliminate
  68                                               // copying it when unnec.
  69     int                     numSystemEntries;
  70     HPALETTE                logicalPalette;
  71 
  72     AwtWin32GraphicsDevice  *device;
  73     unsigned char           *systemInverseLUT;
  74 
  75     /**
  76      * This custom palette is derived from the IE palette.
  77      * Previously, we used a custom palette that used a patented
  78      * algorithm for getting an evently distributed color space.
  79      * But given the realites of desktop and web graphics, it seems
  80      * more important to use a more standard palette, especially one
  81      * that agrees with the predominant browser.  The browser uses
  82      * a slightly modified 6x6x6 colorcube plus a gray ramp plus a
  83      * few other colors.  We still flash with Netscape, but we end
  84      * up using a very similar palette (Netscape uses a 6x6x6 color
< prev index next >