package com.inspect.infrared;

import com.inspect.base.core.utils.ByteUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;

@Setter
@Getter
public class InfraredImage {
    private int width;
    private int height;
    private int byteNum;
    private double weatherT;
    private byte[] bytes;

    public void load(byte[] bytes, int offset) {
        byte[] width = Arrays.copyOfRange(bytes, offset + 2, offset + 4);
        this.width = ByteUtil.getShort(width);
        byte[] height = Arrays.copyOfRange(bytes, offset + 4, offset + 6);
        this.height = ByteUtil.getShort(height);
        this.byteNum = this.width * this.height * 4;
        this.bytes = Arrays.copyOfRange(bytes, offset + 20, offset + 20 + this.byteNum);
        this.weatherT = ByteUtil.getFloat(Arrays.copyOfRange(bytes, offset + 24 + this.byteNum, offset + 28 + this.byteNum));
    }

}
