-
Notifications
You must be signed in to change notification settings - Fork 4
/
pic-packet.ts
40 lines (35 loc) · 882 Bytes
/
pic-packet.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Writer } from '../../writer';
import { Reader } from '../../reader';
import { PacketType } from '../../packet-type';
import { Packet } from '../../packet';
/**
* A packet which contains a bitmap image.
*/
export class PicPacket implements Packet {
type = PacketType.PIC;
propagate = true;
//#region packet-specific members
/**
* The width of the image.
*/
width: number;
/**
* The height of the image.
*/
height: number;
/**
* The bitmap data of the image.
*/
bitmapData: number[];
//#endregion
read(reader: Reader): void {
this.width = reader.readInt32();
this.height = reader.readInt32();
this.bitmapData = reader.readBytes(this.width * this.height * 4);
}
write(writer: Writer): void {
writer.writeInt32(this.width);
writer.writeInt32(this.height);
writer.writeByteArray(this.bitmapData);
}
}