-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rect.cpp
68 lines (50 loc) · 1.18 KB
/
Rect.cpp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* File: Rect.cpp
* Author: brucewang
*
* Created on October 24, 2009, 9:09 PM
*/
#include "Rect.h"
int Rect::GetSize(){
return iTotalBytes;
}
int Rect::XMin() {
return xMin;
}
int Rect::XMax() {
return xMax;
}
int Rect::YMin() {
return yMin;
}
int Rect::YMax() {
return yMax;
}
Rect::Rect(){
}
Rect::Rect(SWFReader *swf){
Read(swf);
}
int Rect::Read(SWFReader *swf) {
nBits = (int) swf->ReadUB(5);
xMin = swf->ReadSB(nBits);
xMax = swf->ReadSB(nBits);
yMin = swf->ReadSB(nBits);
yMax = swf->ReadSB(nBits);
printf( " Rect : %d, %d, %d, %d\n", xMin/20, yMin/20, xMax/20, yMax/20 );
iTotalBytes = (int) ((5 + nBits * 4) / 8);
iTotalBytes += ((5 + nBits * 4) % 8) > 0 ? 1 : 0;
return iTotalBytes;
}
int Rect::Write(SWFWriter *swf){
//SWFWriter::WriteUB()
swf->WriteUB(nBits,5);
swf->WriteSB(xMin,nBits);
swf->WriteSB(xMax,nBits);
swf->WriteSB(yMin,nBits);
swf->WriteSB(yMax,nBits);
printf( " Rect : %d, %d, %d, %d\n", xMin/20, yMin/20, xMax/20, yMax/20 );
iTotalBytes = (int) ((5 + nBits * 4) / 8);
iTotalBytes += ((5 + nBits * 4) % 8) > 0 ? 1 : 0;
return iTotalBytes;
}