Package ch.blackspirit.graphics

Examples of ch.blackspirit.graphics.BufferType


//          bi.setRGB(x, y, (a << 24 & 0xFF000000) + (r << 16 & 0x00FF0000) + (g << 8 & 0x0000FF00) + (b  & 0x000000FF));
//        }
//      }
//      return bi;
//    } else {
      BufferType type = image.getBufferType();

      BufferedImage bi = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
      Color4f color = new Color4f();
      for(int y = 0; y < image.getHeight(); y++) {
        for(int x = 0; x < image.getWidth(); x++) {
          type.getColor(image, x, y, color);
          int r = (int)(color.x * 255);
          int g = (int)(color.y * 255);
          int b = (int)(color.z * 255);
          int a = (int)(color.w * 255);
          bi.setRGB(x, y, (a << 24 & 0xFF000000) + (r << 16 & 0x00FF0000) + (g << 8 & 0x0000FF00) + (b  & 0x000000FF));
View Full Code Here


   * @param image The image to draw the gradient on.
   */
  public void drawGradient(Image image) {
    if(image.isBuffered() == false) throw new IllegalArgumentException("Only buffered images can be processed!");
    if(pointSources.size() == 0 && lineSources.size() == 0) return;
    BufferType bufferType = image.getBufferType();
    Color4f color = new Color4f();
    for(int x = 0; x < image.getWidth(); x++) {
      for(int y = 0; y < image.getHeight(); y++) {
        getColor(x, y, color);
        bufferType.setColor(image, x, y, color);
      }
    }
  }
View Full Code Here

*
*/
public final class BufferTypeUtil {
  public static BufferType getBest(ImageFactory imageFactory, boolean alphaSupport) {
    int currentBits = 0;
    BufferType current = null;
   
    for (BufferType type: imageFactory.getSupportedBufferTypes()) {
      if (type.isAlphaSupported() == alphaSupport && type.getBitsPerPixel() > currentBits) {
        currentBits = type.getBitsPerPixel();
        current = type;
View Full Code Here

      byte[] rawData =(byte[])(buffer.getData());
   
      try {
          imageLock.lock();
 
          BufferType bufferType = backBuffer.getBufferType();
     
          if(bufferType == BufferTypes.RGB_3Byte) {
            // Handle a RGB_3Byte buffer efficiently
            byte[] data = (byte[])backBuffer.getBuffer();
            int width = backBuffer.getWidth();
          int ip = 0;
            for ( int y = inHeight - 1; y >= 0; y-- ) {
            for ( int x = 0; x < inWidth; x++) {
              int indexBase = (y * width + x) * 3;
              data[indexBase + 2] = rawData[ip++];
              data[indexBase + 1] = rawData[ip++];
              data[indexBase] = rawData[ip++];
            }
          }
          } else if(bufferType == BufferTypes.RGBA_4Byte) {
            // Handle a RGBA_4Byte buffer efficiently
            byte[] data = (byte[])backBuffer.getBuffer();
            int width = backBuffer.getWidth();
          int ip = 0;
            for ( int y = inHeight - 1; y >= 0; y-- ) {
            for ( int x = 0; x < inWidth; x++) {
              int indexBase = (y * width + x) * 4;
              data[indexBase + 2] = rawData[ip++];
              data[indexBase + 1] = rawData[ip++];
              data[indexBase] = rawData[ip++];
              data[indexBase + 3] = (byte)255;
            }
          }
          } else {
            // Handling an unknown buffer will be pretty inefficient!
          int ip = 0;
          Color4f color = new Color4f();
          color.w = 1.0f;
          float v = 1.0f / 255;
            for ( int y = inHeight - 1; y >= 0; y-- ) {
            for ( int x = 0; x < inWidth; x++) {
              color.z = v * (int)rawData[ip++];
              color.y = v * (int)rawData[ip++];
              color.x = v * (int)rawData[ip++];
              bufferType.setColor(backBuffer, x, y, color);
            }
          }
          }
 
        updated = true;
View Full Code Here

TOP

Related Classes of ch.blackspirit.graphics.BufferType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.