ChildrenCatsunicodereader jar属哪个jar

当前访客身份:游客 [
当前位置:
你好,想跟你请教个问题:小弟刚学习jogl,今天看了大虾写的一个“jogl简单例子”。有一个类LessonEight.java 中用到 TextureReader,我找了半天,没发现jogl提供的jar包里有这个类。 能不能提供以下jar包。非常感谢!
共有2个答案
<span class="a_vote_num" id="a_vote_num_
import java.awt.image.BufferedI
import java.awt.image.PixelG
import java.io.IOE
import java.nio.ByteB
import javax.imageio.ImageIO;
import com.sun.opengl.util.BufferU
&* Image loading class that converts BufferedImages into a data&
&* structure that can be easily passed to OpenGL.&
&* 图片导入类:将位图转化为OpenGL容易读取的是数据格式&
public class TextureReader {
& & &* 通过文件名读取纹理&
& & &* @param filename 文件的路径名&
& & &* @throws IOException&
& & public static Texture readTexture(String filename) throws IOException { &
& & & & return readTexture(filename,false); &
& & public static Texture readTexture(String filename, boolean storeAlphaChannel) throws IOException { &
& & & & BufferedImage bufferedI &
& & & & if (filename.endsWith(&.bmp&)) { &
& & & & & & bufferedImage = BitmapLoader.loadBitmap(filename); &
& & & & } else { &
& & & & & & bufferedImage = readImage(filename); &
& & & & } &
& & & & return readPixels(bufferedImage, storeAlphaChannel); &
& & &* 读取图片到 BufferedImage&
& & &* @param resourceName&
& & &* @return&
& & &* @throws IOException&
& & private static BufferedImage readImage(String resourceName) throws IOException { &
& & & & return ImageIO.read(TextureReader.class.getResourceAsStream(resourceName)); &
& & &* 读取像素信息&
& & &* @param img 要读取的图片&
& & &* @param storeAlphaChannel 是否有Alpha 通道&
& & &* @return&
& & private static Texture readPixels(BufferedImage img, boolean storeAlphaChannel) { &
& & & & int[] packedPixels = new int[img.getWidth() * img.getHeight()]; &
& & & & /**&
& & & & &* 创建一个 PixelGrabber 对象,以从指定 Img 所生成的图像中将像素矩形部分 (x, y, w, h) 抓取到给定的数组(packedPixels)中。&
& & & & &*/ &
& & & & PixelGrabber pixelgrabber = new PixelGrabber(img, 0, 0, img.getWidth(), img.getHeight(), packedPixels, 0, img.getWidth()); &
& & & & try { &
& & & & & & //请求 Image 或 ImageProducer 开始传递像素,并等待传递完相关矩形中的所有像素 &
& & & & & & pixelgrabber.grabPixels(); &
& & & & } catch (InterruptedException e) { &
& & & & & & throw new RuntimeException(); &
& & & & } &
& & & & //如果为4通道 则说明除了RGB 还有 alpha 值 否则只有 RGB值 &
& & & & int bytesPerPixel = storeAlphaChannel ? 4 : 3; &
& & & & //建立一个新的解包的像素缓冲区 &
& & & & ByteBuffer unpackedPixels = BufferUtil.newByteBuffer(packedPixels.length * bytesPerPixel); &
& & & & //将img中的RGB的整形值 转换为 Byte类型的 数据缓冲 &
& & & & for (int row = img.getHeight() - 1; row &= 0; row--) { &
& & & & & & for (int col = 0; col & img.getWidth(); col++) { &
& & & & & & & & int packedPixel = packedPixels[row * img.getWidth() + col]; &
& & & & & & & & unpackedPixels.put((byte) ((packedPixel && 16) & 0xFF)); &
& & & & & & & & unpackedPixels.put((byte) ((packedPixel && 8) & 0xFF)); &
& & & & & & & & unpackedPixels.put((byte) ((packedPixel && 0) & 0xFF)); &
& & & & & & & & if (storeAlphaChannel) { &
& & & & & & & & & & unpackedPixels.put((byte) ((packedPixel && 24) & 0xFF)); &
& & & & & & & & } &
& & & & & & } &
& & & & } &
& & & & //将缓冲区中的数据反转 &
& & & & unpackedPixels.flip(); &
& & & & return new Texture(unpackedPixels, img.getWidth(), img.getHeight()); &
& & &* 用来存储纹理信息的类&
& & public static class Texture { &
& & & & /**&
& & & & &* 像素&
& & & & &*/ &
& & & & private ByteB &
& & & & /**&
& & & & &* 宽&
& & & & &*/ &
& & & & /**&
& & & & &* 高&
& & & & &*/ &
& & & & public Texture(ByteBuffer pixels, int width, int height) { &
& & & & & & this.height = &
& & & & & & this.pixels = &
& & & & & & this.width = &
& & & & } &
& & & & public int getHeight() { &
& & & & & & &
& & & & } &
& & & & public ByteBuffer getPixels() { &
& & & & & & &
& & & & } &
& & & & public int getWidth() { &
& & & & & & &
& & & & } &
<span class="a_vote_num" id="a_vote_num_
谢谢哈!受益匪浅... 顶你。
更多开发者职位上
有什么技术问题吗?
笑吃人生的其它问题Grammar Girl : Proofreading Tips :: Quick and Dirty Tips (TM)Children’s Books Catalogue
by Forlagid - issuu
Children’s Books Catalogue
Children’s Books Catalogue
Children’s Books Catalogue
Forlagid Publishing Iceland

我要回帖

更多关于 com.csvreader jar 的文章

 

随机推荐