⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alphablender.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        storeRGB(baseIndex++, r31, g31, b31);        return baseIndex;    }    //     private void storeRGB_(int baseIndex, int m) {//        int r = 0, g = 0, b = 0;//        for (int i = 0; i < groups.length; i++) {//            AlphaBlendGroup group = groups[i];//            int bits = (m >> group.groupShift) & group.groupMask;//            int red = group.redMap[bits];//            int green = group.greenMap[bits];//            int blue = group.blueMap[bits];//            int ia = group.inverseAlphaMap[bits];//            if (ia == 0) {//                r = red >> SCALE_SH;//                g = green >> SCALE_SH;//                b = blue >> SCALE_SH;//            } else if (ia != SCALE) {//                r = (red + r * ia) >> SCALE_SH;//                g = (green + g * ia) >> SCALE_SH;//                b = (blue + b * ia) >> SCALE_SH;//            }//        }//        assert 0 <= r && r <= 255;//        assert 0 <= g && g <= 255;//        assert 0 <= b && b <= 255;//        int color = (r << 16) | (g << 8) + b;//        opaqueData[baseIndex] = color;//    }        private void storeRGB(int baseIndex, int red, int green, int blue) {        int color;        if (((red | green | blue) & ~0xFF) == 0) {            color = (red << 16) | (green << 8) | blue;        } else {            color = normalizeRgbDim(red, green, blue);        }        opaqueData[baseIndex] = color;    }    //    private int normalizeRgbHighlight(int red, int green, int blue) {//        return 0xFFFFFF;//    }//    //    private int normalizeRgbClip(int red, int green, int blue) {//        red = Math.max(0, Math.min(0xFF, red));//        green = Math.max(0, Math.min(0xFF, red));//        blue = Math.max(0, Math.min(0xFF, red));//        return (red << 16) | (green << 8) | blue;//    }        private int normalizeRgbDim(int red, int green, int blue) {        int min, max;        if (red <= green) {            min = red;            max = green;        } else {            min = green;            max = red;        }        if (blue > max)            max = blue;        if (blue < min)            min = blue;                if (max - min <= 255) {            int dec = min < 0 ? min : max - 255;            red -= dec;            green -= dec;            blue -= dec;        } else {            int dec = max - 255;            red = Math.max(0, red - dec);            green = Math.max(0, green - dec);            blue = Math.max(0, blue - dec);        }        return (red << 16) | (green << 8) | blue;    }        //********************************************************************        private class AlphaBlendGroup {        int groupShift;        int groupMask;        int[] redMap;        int[] greenMap;        int[] blueMap;        int[] inverseAlphaMap;        int[][] bits;                AlphaBlendGroup(int[][] bits, List<AbstractDrawing.LayerColor> cols, int offset, int len, boolean fillBackround) {            groupShift = offset;            groupMask = (1 << len) - 1;            int mapLen = 1 << len;            redMap = new int[mapLen];            greenMap = new int[mapLen];            blueMap = new int[mapLen];            inverseAlphaMap = new int[mapLen];            this.bits = new int[len][];                        for (int i = 0; i < len; i++) {                this.bits[i] = bits[offset + i];            }                        float[] backgroundComps = background.getRGBColorComponents(null);            float bRed = backgroundComps[0];            float bGreen = backgroundComps[1];            float bBlue = backgroundComps[2];            for (int k = 0; k < mapLen; k++) {                double red = 0, green = 0, blue = 0, ia = 1.0;                if (fillBackround) {                    red = bRed;                    green = bGreen;                    blue = bBlue;                    ia = 0.0;                }                for (int i = 0; i < len; i++) {                    if ((k & (1 << i)) == 0) continue;                    AbstractDrawing.LayerColor lc = cols.get(offset + i);                    double iAlpha = lc.inverseAlpha;                    red *= iAlpha;                    green *= iAlpha;                    blue *= iAlpha;                    ia *= iAlpha;                    red += lc.premultipliedRed;                    green += lc.premultipliedGreen;                    blue += lc.premultipliedBlue;                }                redMap[k] = (int)(red*SCALE*255);                greenMap[k] = (int)(green*SCALE*255);                blueMap[k] = (int)(blue*SCALE*255);                inverseAlphaMap[k] = (int)(ia*SCALE);            }        }                private void unpackBytes(int index) {            // unpack pixels            int pixel0 = 0, pixel1 = 0, pixel2 = 0, pixel3 = 0, pixel4 = 0, pixel5 = 0, pixel6 = 0, pixel7 = 0;            int pixel8 = 0, pixel9 = 0, pixel10 = 0, pixel11 = 0, pixel12 = 0, pixel13 = 0, pixel14 = 0, pixel15 = 0;            int pixel16 = 0, pixel17 = 0, pixel18 = 0, pixel19 = 0, pixel20 = 0, pixel21 = 0, pixel22 = 0, pixel23 = 0;            int pixel24 = 0, pixel25 = 0, pixel26 = 0, pixel27 = 0, pixel28 = 0, pixel29 = 0, pixel30 = 0, pixel31 = 0;            for (int i = 0; i < bits.length; i++) {                int value = bits[i][index];                if (value == 0) continue;                pixel0 |= (value & 1) << i;                pixel1 |= ((value >> 1) & 1) << i;                pixel2 |= ((value >> 2) & 1) << i;                pixel3 |= ((value >> 3) & 1) << i;                pixel4 |= ((value >> 4) & 1) << i;                pixel5 |= ((value >> 5) & 1) << i;                pixel6 |= ((value >> 6) & 1) << i;                pixel7 |= ((value >> 7) & 1) << i;                pixel8 |= ((value >> 8) & 1) << i;                pixel9 |= ((value >> 9) & 1) << i;                pixel10 |= ((value >> 10) & 1) << i;                pixel11 |= ((value >> 11) & 1) << i;                pixel12 |= ((value >> 12) & 1) << i;                pixel13 |= ((value >> 13) & 1) << i;                pixel14 |= ((value >> 14) & 1) << i;                pixel15 |= ((value >> 15) & 1) << i;                pixel16 |= ((value >> 16) & 1) << i;                pixel17 |= ((value >> 17) & 1) << i;                pixel18 |= ((value >> 18) & 1) << i;                pixel19 |= ((value >> 19) & 1) << i;                pixel20 |= ((value >> 20) & 1) << i;                pixel21 |= ((value >> 21) & 1) << i;                pixel22 |= ((value >> 22) & 1) << i;                pixel23 |= ((value >> 23) & 1) << i;                pixel24 |= ((value >> 24) & 1) << i;                pixel25 |= ((value >> 25) & 1) << i;                pixel26 |= ((value >> 26) & 1) << i;                pixel27 |= ((value >> 27) & 1) << i;                pixel28 |= ((value >> 28) & 1) << i;                pixel29 |= ((value >> 29) & 1) << i;                pixel30 |= ((value >> 30) & 1) << i;                pixel31 |= ((value >> 31) & 1) << i;            }                        //             int red, green, blue, ia;                        red = redMap[pixel0];            green = greenMap[pixel0];            blue = blueMap[pixel0];            ia = inverseAlphaMap[pixel0];            if (ia == 0) {                r0 = red >> SCALE_SH;                g0 = green >> SCALE_SH;                b0 = blue >> SCALE_SH;            } else if (ia != SCALE) {                r0 = (red + r0 * ia) >> SCALE_SH;                g0 = (green + g0 * ia) >> SCALE_SH;                b0 = (blue + b0 * ia) >> SCALE_SH;            }            red = redMap[pixel1];            green = greenMap[pixel1];            blue = blueMap[pixel1];            ia = inverseAlphaMap[pixel1];            if (ia == 0) {                r1 = red >> SCALE_SH;                g1 = green >> SCALE_SH;                b1 = blue >> SCALE_SH;            } else if (ia != SCALE) {                r1 = (red + r1 * ia) >> SCALE_SH;                g1 = (green + g1 * ia) >> SCALE_SH;                b1 = (blue + b1 * ia) >> SCALE_SH;            }            red = redMap[pixel2];            green = greenMap[pixel2];            blue = blueMap[pixel2];            ia = inverseAlphaMap[pixel2];            if (ia == 0) {                r2 = red >> SCALE_SH;                g2 = green >> SCALE_SH;                b2 = blue >> SCALE_SH;            } else if (ia != SCALE) {                r2 = (red + r2 * ia) >> SCALE_SH;                g2 = (green + g2 * ia) >> SCALE_SH;                b2 = (blue + b2 * ia) >> SCALE_SH;            }            red = redMap[pixel3];            green = greenMap[pixel3];            blue = blueMap[pixel3];            ia = inverseAlphaMap[pixel3];            if (ia == 0) {                r3 = red >> SCALE_SH;                g3 = green >> SCALE_SH;                b3 = blue >> SCALE_SH;            } else if (ia != SCALE) {                r3 = (red + r3 * ia) >> SCALE_SH;                g3 = (green + g3 * ia) >> SCALE_SH;                b3 = (blue + b3 * ia) >> SCALE_SH;            }            red = redMap[pixel4];            green = greenMap[pixel4];            blue = blueMap[pixel4];            ia = inverseAlphaMap[pixel4];            if (ia == 0) {                r4 = red >> SCALE_SH;                g4 = green >> SCALE_SH;                b4 = blue >> SCALE_SH;            } else if (ia != SCALE) {                r4 = (red + r4 * ia) >> SCALE_SH;                g4 = (green + g4 * ia) >> SCALE_SH;                b4 = (blue + b4 * ia) >> SCALE_SH;            }            red = redMap[pixel5];            green = greenMap[pixel5];            blue = blueMap[pixel5];            ia = inverseAlphaMap[pixel5];            if (ia == 0) {                r5 = red >> SCALE_SH;                g5 = green >> SCALE_SH;                b5 = blue >> SCALE_SH;            } else if (ia != SCALE) {                r5 = (red + r5 * ia) >> SCALE_SH;                g5 = (green + g5 * ia) >> SCALE_SH;                b5 = (blue + b5 * ia) >> SCALE_SH;            }            red = redMap[pixel6];            green = greenMap[pixel6];            blue = blueMap[pixel6];            ia = inverseAlphaMap[pixel6];            if (ia == 0) {                r6 = red >> SCALE_SH;                g6 = green >> SCALE_SH;                b6 = blue >> SCALE_SH;            } else if (ia != SCALE) {                r6 = (red + r6 * ia) >> SCALE_SH;                g6 = (green + g6 * ia) >> SCALE_SH;                b6 = (blue + b6 * ia) >> SCALE_SH;            }            red = redMap[pixel7];            green = greenMap[pixel7];            blue = blueMap[pixel7];            ia = inverseAlphaMap[pixel7];            if (ia == 0) {                r7 = red >> SCALE_SH;                g7 = green >> SCALE_SH;                b7 = blue >> SCALE_SH;            } else if (ia != SCALE) {                r7 = (red + r7 * ia) >> SCALE_SH;                g7 = (green + g7 * ia) >> SCALE_SH;                b7 = (blue + b7 * ia) >> SCALE_SH;            }            red = redMap[pixel8];            green = greenMap[pixel8];            blue = blueMap[pixel8];            ia = inverseAlphaMap[pixel8];            if (ia == 0) {                r8 = red >> SCALE_SH;                g8 = green >> SCALE_SH;                b8 = blue >> SCALE_SH;            } else if (ia != SCALE) {                r8 = (red + r8 * ia) >> SCALE_SH;                g8 = (green + g8 * ia) >> SCALE_SH;                b8 = (blue + b8 * ia) >> SCALE_SH;            }            red = redMap[pixel9];            green = greenMap[pixel9];            blue = blueMap[pixel9];            ia = inverseAlphaMap[pixel9];            if (ia == 0) {                r9 = red >> SCALE_SH;                g9 = green >> SCALE_SH;                b9 = blue >> SCALE_SH;            } else if (ia != SCALE) {                r9 = (red + r9 * ia) >> SCALE_SH;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -