view src/main/java/jp/ac/u_ryukyu/ie/cr/DecodeInfomation.java @ 26:f1dc728ffe87

refactor
author sugi
date Sun, 09 Nov 2014 11:40:01 +0900
parents src/main/java/com/glavsoft/rfb/encoding/decoder/AliceVNCMessage.java@bf9480332e72
children
line wrap: on
line source

package jp.ac.u_ryukyu.ie.cr;

import org.msgpack.annotation.Message;

import com.glavsoft.rfb.encoding.EncodingType;
import com.glavsoft.rfb.encoding.PixelFormat;
import com.glavsoft.rfb.encoding.ServerInitMessage;
import com.glavsoft.rfb.encoding.decoder.FramebufferUpdateRectangle;

@Message
public class DecodeInfomation {
    public int x;
    public int y;
    public int width;
    public int height;
    public int encodingTypeId;
    public String name;

    // use RichCursorDecoder
    public byte[] bitmask;

    // pixel format info
    public byte bitsPerPixel;
    public byte depth;
    public byte bigEndianFlag;
    public byte trueColourFlag;
    public short redMax;
    public short greenMax;
    public short blueMax;
    public byte redShift;
    public byte greenShift;
    public byte blueShift;

    public DecodeInfomation(){

    }

    public void setRectangle(FramebufferUpdateRectangle rect){
        x = rect.x;
        y = rect.y;
        width = rect.width;
        height = rect.height;
        encodingTypeId = rect.getEncodingType().getId();
    }

    public FramebufferUpdateRectangle getFramebufferUpdateRectangle(){
        FramebufferUpdateRectangle rect =
                new FramebufferUpdateRectangle(x, y, width, height);
        rect.encodingType = EncodingType.byId(encodingTypeId);

        return rect;
    }

    public EncodingType getEncodingType() {
        return EncodingType.byId(encodingTypeId);
    }

    public void setPixelFormat(PixelFormat pixelFormat) {
        bitsPerPixel = pixelFormat.bitsPerPixel;
        depth = pixelFormat.depth;
        bigEndianFlag = pixelFormat.bigEndianFlag;
        trueColourFlag = pixelFormat.trueColourFlag;
        redMax = pixelFormat.redMax;
        greenMax = pixelFormat.greenMax;
        blueMax = pixelFormat.blueMax;
        redShift = pixelFormat.redShift;
        greenShift = pixelFormat.greenShift;
        blueShift = pixelFormat.blueShift;
    }

    public PixelFormat getPixelFormat(){
        PixelFormat pixelFormat = new PixelFormat();

        pixelFormat.bitsPerPixel = bitsPerPixel;
        pixelFormat.depth = depth;
        pixelFormat.bigEndianFlag = bigEndianFlag;
        pixelFormat.trueColourFlag = trueColourFlag;
        pixelFormat.redMax = redMax;
        pixelFormat.greenMax = greenMax;
        pixelFormat.blueMax = blueMax;
        pixelFormat.redShift = redShift;
        pixelFormat.greenShift = greenShift;
        pixelFormat.blueShift = blueShift;

        return pixelFormat;
    }

    public void setServerInitMessage(ServerInitMessage serverInitMessage) {
        setPixelFormat(serverInitMessage.getPixelFormat());
        width = serverInitMessage.getFrameBufferWidth();
        height = serverInitMessage.getFrameBufferHeight();
        name = serverInitMessage.getName();

    }
}