CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/external/source/vncdll/winvnc/translate.cpp
Views: 11780
1
/*
2
* translate.c - translate between different pixel formats
3
*/
4
5
/*
6
* Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
7
*
8
* This is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
12
*
13
* This software is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this software; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21
* USA.
22
*/
23
24
#include "stdhdrs.h"
25
26
#include "translate.h"
27
#include <stdio.h>
28
#include "rfb.h"
29
30
#define CONCAT2(a,b) a##b
31
#define CONCAT2E(a,b) CONCAT2(a,b)
32
#define CONCAT4(a,b,c,d) a##b##c##d
33
#define CONCAT4E(a,b,c,d) CONCAT4(a,b,c,d)
34
35
#define OUTBPP 8
36
#include "tableinittctemplate.cpp"
37
#include "tableinitcmtemplate.cpp"
38
#define INBPP 8
39
#include "tabletranstemplate.cpp"
40
#undef INBPP
41
#define INBPP 16
42
#include "tabletranstemplate.cpp"
43
#undef INBPP
44
#define INBPP 32
45
#include "tabletranstemplate.cpp"
46
#undef INBPP
47
#undef OUTBPP
48
49
#define OUTBPP 16
50
#include "tableinittctemplate.cpp"
51
#include "tableinitcmtemplate.cpp"
52
#define INBPP 8
53
#include "tabletranstemplate.cpp"
54
#undef INBPP
55
#define INBPP 16
56
#include "tabletranstemplate.cpp"
57
#undef INBPP
58
#define INBPP 32
59
#include "tabletranstemplate.cpp"
60
#undef INBPP
61
#undef OUTBPP
62
63
#define OUTBPP 32
64
#include "tableinittctemplate.cpp"
65
#include "tableinitcmtemplate.cpp"
66
#define INBPP 8
67
#include "tabletranstemplate.cpp"
68
#undef INBPP
69
#define INBPP 16
70
#include "tabletranstemplate.cpp"
71
#undef INBPP
72
#define INBPP 32
73
#include "tabletranstemplate.cpp"
74
#undef INBPP
75
#undef OUTBPP
76
77
rfbInitTableFnType rfbInitTrueColourSingleTableFns[3] = {
78
rfbInitTrueColourSingleTable8,
79
rfbInitTrueColourSingleTable16,
80
rfbInitTrueColourSingleTable32
81
};
82
83
rfbInitTableFnType rfbInitColourMapSingleTableFns[3] = {
84
rfbInitColourMapSingleTable8,
85
rfbInitColourMapSingleTable16,
86
rfbInitColourMapSingleTable32
87
};
88
89
rfbInitTableFnType rfbInitTrueColourRGBTablesFns[3] = {
90
rfbInitTrueColourRGBTables8,
91
rfbInitTrueColourRGBTables16,
92
rfbInitTrueColourRGBTables32
93
};
94
95
rfbTranslateFnType rfbTranslateWithSingleTableFns[3][3] = {
96
{ rfbTranslateWithSingleTable8to8,
97
rfbTranslateWithSingleTable8to16,
98
rfbTranslateWithSingleTable8to32 },
99
{ rfbTranslateWithSingleTable16to8,
100
rfbTranslateWithSingleTable16to16,
101
rfbTranslateWithSingleTable16to32 },
102
{ rfbTranslateWithSingleTable32to8,
103
rfbTranslateWithSingleTable32to16,
104
rfbTranslateWithSingleTable32to32 }
105
};
106
107
rfbTranslateFnType rfbTranslateWithRGBTablesFns[3][3] = {
108
{ rfbTranslateWithRGBTables8to8,
109
rfbTranslateWithRGBTables8to16,
110
rfbTranslateWithRGBTables8to32 },
111
{ rfbTranslateWithRGBTables16to8,
112
rfbTranslateWithRGBTables16to16,
113
rfbTranslateWithRGBTables16to32 },
114
{ rfbTranslateWithRGBTables32to8,
115
rfbTranslateWithRGBTables32to16,
116
rfbTranslateWithRGBTables32to32 }
117
};
118
119
120
121
// rfbTranslateNone is used when no translation is required.
122
123
void
124
rfbTranslateNone(char *table, rfbPixelFormat *in, rfbPixelFormat *out,
125
char *iptr, char *optr, int bytesBetweenInputLines,
126
int width, int height)
127
{
128
int bytesPerOutputLine = width * (out->bitsPerPixel / 8);
129
130
while (height > 0) {
131
memcpy(optr, iptr, bytesPerOutputLine);
132
iptr += bytesBetweenInputLines;
133
optr += bytesPerOutputLine;
134
height--;
135
}
136
}
137
138
139