Code example for Bitmap

Methods: getConfiggetHeightgetWidthrecycletexImage2D

0
        } 
    } 
     
    private void createMipmaps(GL10 gl, Bitmap bitmap) {
        gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId);
        width = bitmap.getWidth();
        height = bitmap.getHeight();        
        setFilters(GL10.GL_LINEAR_MIPMAP_NEAREST, GL10.GL_LINEAR);
         
        int level = 0;
        int newWidth = width;
        int newHeight = height;
        while(true) { 
            GLUtils.texImage2D(GL10.GL_TEXTURE_2D, level, bitmap, 0);
            newWidth = newWidth / 2;
            newHeight = newHeight / 2;
            if(newWidth <= 0)
                break; 
            Bitmap newBitmap = Bitmap.createBitmap(newWidth, newHeight, bitmap.getConfig());
            Canvas canvas = new Canvas(newBitmap);
            canvas.drawBitmap(bitmap, 
                              new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()),
                              new Rect(0, 0, newWidth, newHeight),
                              null);             
            bitmap.recycle();
            bitmap = newBitmap;
            level++;
        } 
         
        gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);        
        bitmap.recycle();
    } 
     
    public void reload() { 
        load(); 
        bind(); 
Experience pair programming with AI  Get Codota for Java