亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? labelmaker.java

?? Android Source Code. An gallary program.
?? JAVA
字號(hào):
/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package com.example.android.apis.graphics.spritetext;import android.graphics.Bitmap;import android.graphics.Canvas;import android.graphics.Paint;import android.graphics.Rect;import android.graphics.Paint.Style;import android.graphics.drawable.Drawable;import android.opengl.GLUtils;import java.util.ArrayList;import javax.microedition.khronos.opengles.GL10;import javax.microedition.khronos.opengles.GL11;import javax.microedition.khronos.opengles.GL11Ext;/** * An OpenGL text label maker. * * * OpenGL labels are implemented by creating a Bitmap, drawing all the labels * into the Bitmap, converting the Bitmap into an Alpha texture, and creating a * mesh for each label * * The benefits of this approach are that the labels are drawn using the high * quality anti-aliased font rasterizer, full character set support, and all the * text labels are stored on a single texture, which makes it faster to use. * * The drawbacks are that you can only have as many labels as will fit onto one * texture, and you have to recreate the whole texture if any label text * changes. * */public class LabelMaker {    /**     * Create a label maker     * or maximum compatibility with various OpenGL ES implementations,     * the strike width and height must be powers of two,     * We want the strike width to be at least as wide as the widest window.     *     * @param fullColor true if we want a full color backing store (4444),     * otherwise we generate a grey L8 backing store.     * @param strikeWidth width of strike     * @param strikeHeight height of strike     */    public LabelMaker(boolean fullColor, int strikeWidth, int strikeHeight) {        mFullColor = fullColor;        mStrikeWidth = strikeWidth;        mStrikeHeight = strikeHeight;        mTexelWidth = (float) (1.0 / mStrikeWidth);        mTexelHeight = (float) (1.0 / mStrikeHeight);        mClearPaint = new Paint();        mClearPaint.setARGB(0, 0, 0, 0);        mClearPaint.setStyle(Style.FILL);        mState = STATE_NEW;    }    /**     * Call to initialize the class.     * Call whenever the surface has been created.     *     * @param gl     */    public void initialize(GL10 gl) {        mState = STATE_INITIALIZED;        int[] textures = new int[1];        gl.glGenTextures(1, textures, 0);        mTextureID = textures[0];        gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);        // Use Nearest for performance.        gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,                GL10.GL_NEAREST);        gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,                GL10.GL_NEAREST);        gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,                GL10.GL_CLAMP_TO_EDGE);        gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,                GL10.GL_CLAMP_TO_EDGE);        gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,                GL10.GL_REPLACE);    }    /**     * Call when the surface has been destroyed     */    public void shutdown(GL10 gl) {        if ( gl != null) {            if (mState > STATE_NEW) {                int[] textures = new int[1];                textures[0] = mTextureID;                gl.glDeleteTextures(1, textures, 0);                mState = STATE_NEW;            }        }    }    /**     * Call before adding labels. Clears out any existing labels.     *     * @param gl     */    public void beginAdding(GL10 gl) {        checkState(STATE_INITIALIZED, STATE_ADDING);        mLabels.clear();        mU = 0;        mV = 0;        mLineHeight = 0;        Bitmap.Config config = mFullColor ?                Bitmap.Config.ARGB_4444 : Bitmap.Config.ALPHA_8;        mBitmap = Bitmap.createBitmap(mStrikeWidth, mStrikeHeight, config);        mCanvas = new Canvas(mBitmap);        mBitmap.eraseColor(0);    }    /**     * Call to add a label     *     * @param gl     * @param text the text of the label     * @param textPaint the paint of the label     * @return the id of the label, used to measure and draw the label     */    public int add(GL10 gl, String text, Paint textPaint) {        return add(gl, null, text, textPaint);    }    /**     * Call to add a label     *     * @param gl     * @param text the text of the label     * @param textPaint the paint of the label     * @return the id of the label, used to measure and draw the label     */    public int add(GL10 gl, Drawable background, String text, Paint textPaint) {        return add(gl, background, text, textPaint, 0, 0);    }    /**     * Call to add a label     * @return the id of the label, used to measure and draw the label     */    public int add(GL10 gl, Drawable drawable, int minWidth, int minHeight) {        return add(gl, drawable, null, null, minWidth, minHeight);    }    /**     * Call to add a label     *     * @param gl     * @param text the text of the label     * @param textPaint the paint of the label     * @return the id of the label, used to measure and draw the label     */    public int add(GL10 gl, Drawable background, String text, Paint textPaint,            int minWidth, int minHeight) {        checkState(STATE_ADDING, STATE_ADDING);        boolean drawBackground = background != null;        boolean drawText = (text != null) && (textPaint != null);        Rect padding = new Rect();        if (drawBackground) {            background.getPadding(padding);            minWidth = Math.max(minWidth, background.getMinimumWidth());            minHeight = Math.max(minHeight, background.getMinimumHeight());        }        int ascent = 0;        int descent = 0;        int measuredTextWidth = 0;        if (drawText) {            // Paint.ascent is negative, so negate it.            ascent = (int) Math.ceil(-textPaint.ascent());            descent = (int) Math.ceil(textPaint.descent());            measuredTextWidth = (int) Math.ceil(textPaint.measureText(text));        }        int textHeight = ascent + descent;        int textWidth = Math.min(mStrikeWidth,measuredTextWidth);        int padHeight = padding.top + padding.bottom;        int padWidth = padding.left + padding.right;        int height = Math.max(minHeight, textHeight + padHeight);        int width = Math.max(minWidth, textWidth + padWidth);        int effectiveTextHeight = height - padHeight;        int effectiveTextWidth = width - padWidth;        int centerOffsetHeight = (effectiveTextHeight - textHeight) / 2;        int centerOffsetWidth = (effectiveTextWidth - textWidth) / 2;        // Make changes to the local variables, only commit them        // to the member variables after we've decided not to throw        // any exceptions.        int u = mU;        int v = mV;        int lineHeight = mLineHeight;        if (width > mStrikeWidth) {            width = mStrikeWidth;        }        // Is there room for this string on the current line?        if (u + width > mStrikeWidth) {            // No room, go to the next line:            u = 0;            v += lineHeight;            lineHeight = 0;        }        lineHeight = Math.max(lineHeight, height);        if (v + lineHeight > mStrikeHeight) {            throw new IllegalArgumentException("Out of texture space.");        }        int u2 = u + width;        int vBase = v + ascent;        int v2 = v + height;        if (drawBackground) {            background.setBounds(u, v, u + width, v + height);            background.draw(mCanvas);        }        if (drawText) {            mCanvas.drawText(text,                    u + padding.left + centerOffsetWidth,                    vBase + padding.top + centerOffsetHeight,                    textPaint);        }        Grid grid = new Grid(2, 2);        // Grid.set arguments: i, j, x, y, z, u, v        float texU = u * mTexelWidth;        float texU2 = u2 * mTexelWidth;        float texV = 1.0f - v * mTexelHeight;        float texV2 = 1.0f - v2 * mTexelHeight;        grid.set(0, 0,   0.0f,   0.0f, 0.0f, texU , texV2);        grid.set(1, 0,  width,   0.0f, 0.0f, texU2, texV2);        grid.set(0, 1,   0.0f, height, 0.0f, texU , texV );        grid.set(1, 1,  width, height, 0.0f, texU2, texV );        // We know there's enough space, so update the member variables        mU = u + width;        mV = v;        mLineHeight = lineHeight;        mLabels.add(new Label(grid, width, height, ascent,                u, v + height, width, -height));        return mLabels.size() - 1;    }    /**     * Call to end adding labels. Must be called before drawing starts.     *     * @param gl     */    public void endAdding(GL10 gl) {        checkState(STATE_ADDING, STATE_INITIALIZED);        gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);        GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, mBitmap, 0);        // Reclaim storage used by bitmap and canvas.        mBitmap.recycle();        mBitmap = null;        mCanvas = null;    }    /**     * Get the width in pixels of a given label.     *     * @param labelID     * @return the width in pixels     */    public float getWidth(int labelID) {        return mLabels.get(labelID).width;    }    /**     * Get the height in pixels of a given label.     *     * @param labelID     * @return the height in pixels     */    public float getHeight(int labelID) {        return mLabels.get(labelID).height;    }    /**     * Get the baseline of a given label. That's how many pixels from the top of     * the label to the text baseline. (This is equivalent to the negative of     * the label's paint's ascent.)     *     * @param labelID     * @return the baseline in pixels.     */    public float getBaseline(int labelID) {        return mLabels.get(labelID).baseline;    }    /**     * Begin drawing labels. Sets the OpenGL state for rapid drawing.     *     * @param gl     * @param viewWidth     * @param viewHeight     */    public void beginDrawing(GL10 gl, float viewWidth, float viewHeight) {        checkState(STATE_INITIALIZED, STATE_DRAWING);        gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);        gl.glShadeModel(GL10.GL_FLAT);        gl.glEnable(GL10.GL_BLEND);        gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);        gl.glColor4x(0x10000, 0x10000, 0x10000, 0x10000);        gl.glMatrixMode(GL10.GL_PROJECTION);        gl.glPushMatrix();        gl.glLoadIdentity();        gl.glOrthof(0.0f, viewWidth, 0.0f, viewHeight, 0.0f, 1.0f);        gl.glMatrixMode(GL10.GL_MODELVIEW);        gl.glPushMatrix();        gl.glLoadIdentity();        // Magic offsets to promote consistent rasterization.        gl.glTranslatef(0.375f, 0.375f, 0.0f);    }    /**     * Draw a given label at a given x,y position, expressed in pixels, with the     * lower-left-hand-corner of the view being (0,0).     *     * @param gl     * @param x     * @param y     * @param labelID     */    public void draw(GL10 gl, float x, float y, int labelID) {        checkState(STATE_DRAWING, STATE_DRAWING);        gl.glPushMatrix();        float snappedX = (float) Math.floor(x);        float snappedY = (float) Math.floor(y);        gl.glTranslatef(snappedX, snappedY, 0.0f);        Label label = mLabels.get(labelID);        gl.glEnable(GL10.GL_TEXTURE_2D);        ((GL11)gl).glTexParameteriv(GL10.GL_TEXTURE_2D,                GL11Ext.GL_TEXTURE_CROP_RECT_OES, label.mCrop, 0);        ((GL11Ext)gl).glDrawTexiOES((int) snappedX, (int) snappedY, 0,                (int) label.width, (int) label.height);        gl.glPopMatrix();    }    /**     * Ends the drawing and restores the OpenGL state.     *     * @param gl     */    public void endDrawing(GL10 gl) {        checkState(STATE_DRAWING, STATE_INITIALIZED);        gl.glDisable(GL10.GL_BLEND);        gl.glMatrixMode(GL10.GL_PROJECTION);        gl.glPopMatrix();        gl.glMatrixMode(GL10.GL_MODELVIEW);        gl.glPopMatrix();    }    private void checkState(int oldState, int newState) {        if (mState != oldState) {            throw new IllegalArgumentException("Can't call this method now.");        }        mState = newState;    }    private static class Label {        public Label(Grid grid, float width, float height, float baseLine,                int cropU, int cropV, int cropW, int cropH) {            this.grid = grid;            this.width = width;            this.height = height;            this.baseline = baseLine;            int[] crop = new int[4];            crop[0] = cropU;            crop[1] = cropV;            crop[2] = cropW;            crop[3] = cropH;            mCrop = crop;        }        public Grid grid;        public float width;        public float height;        public float baseline;        public int[] mCrop;    }    private int mStrikeWidth;    private int mStrikeHeight;    private boolean mFullColor;    private Bitmap mBitmap;    private Canvas mCanvas;    private Paint mClearPaint;    private int mTextureID;    private float mTexelWidth;  // Convert texel to U    private float mTexelHeight; // Convert texel to V    private int mU;    private int mV;    private int mLineHeight;    private ArrayList<Label> mLabels = new ArrayList<Label>();    private static final int STATE_NEW = 0;    private static final int STATE_INITIALIZED = 1;    private static final int STATE_ADDING = 2;    private static final int STATE_DRAWING = 3;    private int mState;}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产酒店精品激情| 欧美一区二区三区影视| 国产呦精品一区二区三区网站| 亚洲精品成人精品456| 奇米色777欧美一区二区| 2022国产精品视频| 成人午夜视频在线| 亚洲黄色免费电影| 中文字幕免费不卡在线| 国产亚洲婷婷免费| 久久综合九色综合97婷婷女人 | 一级日本不卡的影视| 亚洲三级在线免费| 国产精品久久久久久妇女6080| 91无套直看片红桃| 成人免费毛片片v| 97精品国产露脸对白| 国产v综合v亚洲欧| 亚洲国产色一区| 久久精品视频在线看| 欧美成人video| 成人精品视频一区二区三区尤物| 久久99久国产精品黄毛片色诱| 久久超碰97人人做人人爱| 国产精品高清亚洲| 国产女主播视频一区二区| 亚洲精品一区二区三区四区高清 | 日本丰满少妇一区二区三区| 亚洲国产毛片aaaaa无费看| 一区二区三区不卡在线观看| 亚洲欧美视频在线观看| 中文字幕av免费专区久久| 亚洲三级理论片| 91精品欧美久久久久久动漫| 欧美一级理论片| 色噜噜狠狠一区二区三区果冻| av电影在线观看完整版一区二区| 粉嫩欧美一区二区三区高清影视| 最近日韩中文字幕| 日韩欧美三级在线| 精品福利二区三区| 国产欧美日韩久久| 91麻豆精品国产91久久久久| 538在线一区二区精品国产| 成人不卡免费av| 欧美中文字幕亚洲一区二区va在线 | 国产精品美女久久久久久久网站| 日韩精品一区二区三区四区视频| av电影在线观看一区| 国模一区二区三区白浆| 亚洲福利国产精品| 国产麻豆午夜三级精品| 青青草97国产精品免费观看 | 欧美视频一区二区三区| 粉嫩aⅴ一区二区三区四区五区| 亚洲国产一区二区三区| 全国精品久久少妇| 亚洲制服丝袜av| 久久精品国产一区二区三| 亚洲美女视频一区| 久久久国产精品不卡| 51精品国自产在线| 久久久久久免费毛片精品| 欧美在线观看视频一区二区三区| 99re成人精品视频| 欧美一区二区网站| 国产欧美日韩麻豆91| 亚洲精品视频自拍| 国产综合成人久久大片91| 国产成人在线观看| 91成人看片片| 国产欧美一区二区精品忘忧草| 久久综合久久综合九色| 亚洲欧美日韩一区| 蜜臀av一级做a爰片久久| 成人精品在线视频观看| 精品视频1区2区3区| 国产亲近乱来精品视频| 日韩精品电影在线| 亚洲动漫第一页| 国产成人精品影院| 高清国产一区二区| 欧美揉bbbbb揉bbbbb| 欧美日韩一区二区电影| 国产色91在线| 美女脱光内衣内裤视频久久网站| 91麻豆国产精品久久| 欧美性猛交一区二区三区精品| 91久久精品国产91性色tv| 欧美一区二视频| 亚洲欧美另类久久久精品| 亚洲摸摸操操av| 国产成人鲁色资源国产91色综| 欧美电影在哪看比较好| 欧美一区二区国产| 欧美一卡2卡三卡4卡5免费| 亚洲视频图片小说| 国产传媒欧美日韩成人| 欧美综合久久久| 国产精品网站导航| 一区二区欧美国产| 成人av影院在线| 国产日产欧美一区二区三区| 日日骚欧美日韩| 欧美在线免费观看视频| 亚洲人成伊人成综合网小说| 亚洲成av人片www| 老司机午夜精品| 日韩欧美高清dvd碟片| 丝袜美腿亚洲一区| 国产一区二区精品久久| 日韩精品一区在线| 蜜乳av一区二区| 欧美伦理电影网| 久久综合国产精品| 麻豆精品一区二区| 91精品国产福利| 图片区小说区国产精品视频| 91猫先生在线| 亚洲免费在线视频| 国产精品18久久久久久久久久久久 | 欧美丝袜自拍制服另类| 欧美在线视频日韩| 日本一区二区三区四区| av影院午夜一区| 亚洲美女区一区| 波多野结衣的一区二区三区| 亚洲欧美中日韩| 欧美色综合天天久久综合精品| 国产视频不卡一区| 一本在线高清不卡dvd| 亚洲福利电影网| 日韩精品一区二区三区视频播放 | 日韩一区二区三区电影| 国产一区二区中文字幕| 国产精品护士白丝一区av| 日本国产一区二区| 久久精品国产亚洲高清剧情介绍| 久久精品人人做人人爽人人| 99国产精品国产精品久久| 久久精品人人做人人综合 | 六月丁香婷婷久久| 久久精品综合网| 在线精品亚洲一区二区不卡| 麻豆高清免费国产一区| 欧美国产成人在线| 国产电影一区在线| 国产午夜精品久久久久久免费视| 91论坛在线播放| 国产精品国产精品国产专区不蜜| 欧洲精品一区二区| 黑人巨大精品欧美黑白配亚洲| 日韩午夜在线观看| 97精品久久久久中文字幕| 日本女优在线视频一区二区| 中文在线资源观看网站视频免费不卡 | 亚洲国产另类av| 国产亚洲福利社区一区| 欧美日韩一区二区三区视频| 国产成人精品在线看| 精品免费国产一区二区三区四区| 轻轻草成人在线| 国产精品美女久久久久久久久| 成人av电影免费观看| 日韩在线卡一卡二| 日韩一区欧美一区| 色噜噜狠狠色综合欧洲selulu | 欧美日韩一区视频| 国产成人精品在线看| 青青国产91久久久久久 | 91在线视频18| 经典一区二区三区| 亚洲高清不卡在线| 欧美丰满嫩嫩电影| 麻豆视频观看网址久久| 一个色综合av| 5566中文字幕一区二区电影| 91在线免费看| 成人免费视频播放| 亚洲精品日韩专区silk | 国产乱妇无码大片在线观看| 久久久久久久久久久久电影| 精品视频色一区| 美国av一区二区| 亚洲国产精品人人做人人爽| 欧美精品免费视频| 韩国v欧美v亚洲v日本v| 国产精品国产三级国产aⅴ无密码| 精品少妇一区二区三区免费观看 | 欧美高清视频不卡网| 色综合天天综合网天天狠天天| 一区二区三区成人| 亚洲欧美在线视频| 在线不卡中文字幕播放| 精品在线一区二区三区| 国产精品久久久久一区| 在线视频国产一区| 久久99日本精品| 蜜桃精品视频在线| 日韩成人午夜精品|