bitmap.java

来自「jnative java 调用动态库需要的包和dll」· Java 代码 · 共 65 行

JAVA
65
字号
/*
 * BITMAP.java
 *
 * Created on 15. M鋜z 2007, 14:39
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.xvolks.jnative.misc.basicStructures;

import org.xvolks.jnative.exceptions.NativeException;
import org.xvolks.jnative.misc.basicStructures.AbstractBasicData;
import org.xvolks.jnative.pointers.Pointer;
import org.xvolks.jnative.pointers.memory.HeapMemoryBlock;
import org.xvolks.jnative.pointers.memory.MemoryBlockFactory;

/**
 *
 * @author osthop
 */
public class BITMAP extends AbstractBasicData<BITMAP> {
    
    /** Creates a new instance of BITMAP */
    public BITMAP() {
        super(null);
        try {
            createPointer();
        } catch (NativeException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}		
    }
    
    public Pointer createBitmapBuffer() throws NativeException {
        return new Pointer(new HeapMemoryBlock(getNeededBufferSize()));
    }
    
    public int getWidth() throws NativeException {
        return pointer.getAsInt(4);
    }
    public int getHeight() throws NativeException {
        return pointer.getAsInt(8);
    }
    public int getNeededBufferSize() throws NativeException {
        return getWidth()*getHeight()*4;
    }
    public int getRealBitmapSize() throws NativeException {
        return getWidth()*getHeight();
    }
    public Pointer createPointer() throws NativeException {
        pointer = new Pointer(MemoryBlockFactory.createMemoryBlock(getSizeOf()));
		return pointer;
    }
 
    public int getSizeOf() {
        return 24;
    }
    
    public BITMAP getValueFromPointer() {
        return this;
    }
    
}

⌨️ 快捷键说明

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