1 /*******************************************************************************
2 * pvengine.h
3 *
4 * This file contains PVENGINE specific defines.
5 *
6 * Author: Christopher J Cason.
7 *
8 * ---------------------------------------------------------------------------
9 * Persistence of Vision Ray Tracer ('POV-Ray') version 3.7.
10 * Copyright 1991-2013 Persistence of Vision Raytracer Pty. Ltd.
11 *
12 * POV-Ray is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Affero General Public License as
14 * published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * POV-Ray is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
21 *
22 * You should have received a copy of the GNU Affero General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * ---------------------------------------------------------------------------
25 * POV-Ray is based on the popular DKB raytracer version 2.12.
26 * DKBTrace was originally written by David K. Buck.
27 * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
28 * ---------------------------------------------------------------------------
29 * $File: //depot/public/povray/3.x/windows/pvengine.h $
30 * $Revision: #1 $
31 * $Change: 6069 $
32 * $DateTime: 2013/11/06 11:59:40 $
33 * $Author: chrisc $
34 *******************************************************************************/
35
36 #ifndef PVENGINE_H_INCLUDED
37 #define PVENGINE_H_INCLUDED
38
39 #ifdef BUILDING_AMD64
40 #if !defined(_M_AMD64) && !defined(_M_X64)
41 #error you are compiling the x64 project using a 32-bit compiler
42 #endif
43 #else
44 #if defined(_M_AMD64) || defined(_M_X64)
45 #error you are compiling the 32-bit project using a 64-bit compiler
46 #endif
47 #endif
48
49 #ifdef _CONSOLE
50 #error You are building the GUI platform with _CONSOLE defined (check vfe\win\syspovconfig.h).
51 #endif
52
53 #include <string.h>
54 #include <malloc.h>
55 #include <direct.h>
56 #include <io.h>
57 #include <process.h>
58 #include <assert.h>
59 #include <sys/stat.h>
60 #include <excpt.h>
61 #include <stdio.h>
62 #include <stdlib.h>
63
64 #include "pvfrontend.h"
65 #include "frame.h"
66 #include "povray.h"
67
68 #define PVENGINE_VER POVRAY_PLATFORM_NAME
69
70 #include <time.h>
71
72 #define __USECTL3D__
73 #define MAX_MESSAGE 1024
74 #define MAX_ARGV 256
75 #define TOOLFILENAME "PVTOOLS.INI"
76 #define MAX_TOOLCMD 32
77 #define MAX_TOOLCMDTEXT 128
78 #define MAX_TOOLHELPTEXT 128
79 #define MIN_EDITOR_VERSION 100
80 #define MAX_EDITOR_VERSION 199
81 #define MAX_WINDOWS 16
82 #define MAX_EDIT_FILES 32
83 #define POV_INTERNAL_STREAM ((FILE *) 1L)
84
85 #define LEGACY_OPTION_FILE_SUPPORT
86
87 #define EDIT_FILE 1
88 #define RENDER_FILE 2
89
90 #define CRASH_REPORTER_EXECUTABLE "SubmitMinidump.exe"
91
92 #if POV_RAY_IS_OFFICIAL == 1
93 #ifdef _WIN64
94 #define CLASSNAMEPREFIX "Pov37-Win64-"
95 #else
96 #define CLASSNAMEPREFIX "Pov37-Win32-"
97 #endif
98 #else
99 #ifdef _WIN64
100 #define CLASSNAMEPREFIX "Unofficial-Pov37-Win64-"
101 #else
102 #define CLASSNAMEPREFIX "Unofficial-Pov37-Win32-"
103 #endif
104 #endif
105
106 #ifdef DEVELOPMENT
107 #ifdef _WIN64
108 #define CAPTIONPREFIX "[WIN64]"
109 #else
110 #define CAPTIONPREFIX "[WIN32]"
111 #endif
112 #else
113 #define CAPTIONPREFIX ""
114 #endif
115
116 #ifdef _WIN64
117 #define BINDIRNAME "bin64"
118 #define INSTALLTIMEKEY "InstallTime64"
119 #ifdef _DEBUG
120 #define EDITDLLNAME "cmedit64d.dll"
121 #else
122 #define EDITDLLNAME "cmedit64.dll"
123 #endif
124 #if !defined POVRAY_IS_BETA
125 #define NEWESTVERSIONVAL "NewestVersion64"
126 #define VERSIONVAL "VersionNo64"
127 #define NEXTVERSIONCHECKVAL "NextVersionCheck64"
128 #define VERSIONCHECKDAYS 4
129 #else
130 #define NEWESTVERSIONVAL "NewestBetaVersion64"
131 #define VERSIONVAL "BetaVersionNo64"
132 #define NEXTVERSIONCHECKVAL "NextBetaVersionCheck64"
133 #define VERSIONCHECKDAYS 1
134 #endif
135 #else
136 #define BINDIRNAME "bin32"
137 #define INSTALLTIMEKEY "InstallTime32"
138 #ifdef _DEBUG
139 #define EDITDLLNAME "cmedit32d.dll"
140 #else
141 #ifdef BUILD_SSE2
142 #define EDITDLLNAME "cmedit32-sse2.dll"
143 #else
144 #define EDITDLLNAME "cmedit32.dll"
145 #endif
146 #endif
147 #if !defined POVRAY_IS_BETA
148 #define NEWESTVERSIONVAL "NewestVersion32"
149 #define VERSIONVAL "VersionNo32"
150 #define NEXTVERSIONCHECKVAL "NextVersionCheck32"
151 #define VERSIONCHECKDAYS 4
152 #else
153 #define NEWESTVERSIONVAL "NewestBetaVersion32"
154 #define VERSIONVAL "BetaVersionNo32"
155 #define NEXTVERSIONCHECKVAL "NextBetaVersionCheck32"
156 #define VERSIONCHECKDAYS 1
157 #endif
158 #endif
159
160 // ----------------------------------------------------------------------
161 // message definitions used to be here but have been moved to pvedit.h.
162 // ----------------------------------------------------------------------
163
164 #define NUM_BUTTONS 16
165 #define HDIB HANDLE
166 #define SEPARATOR '\\'
167
168 #define DRAWFASTRECT(hdc,lprc) ExtTextOut(hdc,0,0,ETO_OPAQUE,lprc,NULL,0,NULL)
169
170 #define RGBBLACK RGB(0,0,0)
171 #define RGBRED RGB(128,0,0)
172 #define RGBGREEN RGB(0,128,0)
173 #define RGBBLUE RGB(0,0,128)
174
175 #define RGBBROWN RGB(128,128,0)
176 #define RGBMAGENTA RGB(128,0,128)
177 #define RGBCYAN RGB(0,128,128)
178 #define RGBLTGRAY RGB(192,192,192)
179
180 #define RGBGRAY RGB(128,128,128)
181 #define RGBLTRED RGB(255,0,0)
182 #define RGBLTGREEN RGB(0,255,0)
183 #define RGBLTBLUE RGB(0,0,255)
184
185 #define RGBYELLOW RGB(255,255,0)
186 #define RGBLTMAGENTA RGB(255,0,255)
187 #define RGBLTCYAN RGB(0,255,255)
188 #define RGBWHITE RGB(255,255,255)
189
190 namespace povwin
191 {
192
193 // WARNING: also declared in pvguiext.h (for a reason)
194 // KEEP THESE IN SYNC
195 typedef enum
196 {
197 mUnknown = 0,
198 mAll = 1,
199 All = 1,
200 mIDE,
201 mBanner,
202 mWarning,
203 mRender,
204 mStatus,
205 mDebug,
206 mFatal,
207 mStatistics,
208 mDivider,
209 mHorzLine,
210 } msgtype ;
211
212 typedef enum
213 {
214 None,
215 CR,
216 LF
217 } lftype ;
218
219 typedef enum
220 {
221 filePOV,
222 fileINC,
223 fileINI,
224 fileFirstImageType,
225 fileTGA = fileFirstImageType,
226 filePPM,
227 filePGM,
228 filePBM,
229 filePNG,
230 fileGIF,
231 fileBMP,
232 fileEXR,
233 fileLastImageType = fileEXR,
234 fileUnknown
235 } FileType ;
236
237 // Bitmap header info with palette included
238
239 typedef struct
240 {
241 BITMAPINFOHEADER header ;
242 RGBQUAD colors [256] ;
243 } BitmapInfo ;
244
245 // Windows LOGPALETTE palette structure
246
247 typedef struct
248 {
249 WORD version ;
250 WORD entries ;
251 PALETTEENTRY pe [256] ;
252 } LogPal ;
253
254 typedef struct
255 {
256 bool ncEnabled ;
257 bool menuWasUp ;
258 bool hasCaption ;
259 bool hasBorder ;
260 bool hasSizeableBorder ;
261 bool hasStatusBar ;
262 bool hasMenuBar ;
263 bool sysMenuOverride ;
264 bool isMaxiMinimized ;
265 HWND hWnd ;
266 HFONT hMenuBarFont ;
267 HFONT hStatusBarFont ;
268 HFONT hSystemFont ;
269 ushort captionTotal ;
270 ushort captionInternal ;
271 ushort captionBorderLeft ;
272 ushort captionBorderRight ;
273 ushort captionBorderTop ;
274 ushort captionBorderBottom ;
275 ushort borderWidth ;
276 ushort borderHeight ;
277 ushort buttonWidth ;
278 ushort buttonHeight ;
279 ushort sizing ;
280 ushort statusBarTotal ;
281 ushort statusBarBorder ;
282 ushort menuBarTotal ;
283 ushort menuBarBorder ;
284 } pvncStruct ;
285
286 class AutoLock
287 {
288 public:
AutoLock(CRITICAL_SECTION & CriticalSection)289 inline AutoLock (CRITICAL_SECTION& CriticalSection) { m_CriticalSection = &CriticalSection ; EnterCriticalSection (m_CriticalSection) ; }
~AutoLock()290 inline ~AutoLock() { LeaveCriticalSection (m_CriticalSection) ; }
291
292 private:
293 LPCRITICAL_SECTION m_CriticalSection ;
294 };
295
MulDivNoRound(int value,int mul_by,int div_by)296 inline int MulDivNoRound (int value, int mul_by, int div_by)
297 {
298 return ((int) ((__int64) value * mul_by / div_by)) ;
299 }
300
301 extern int delay_next_status ;
302 extern char EngineIniFileName[];
303 extern char BinariesPath[];
304 extern char DocumentsPath[];
305 extern char FontPath[];
306 extern char status_buffer [1024] ;
307 extern HINSTANCE hInstance;
308
309 void ShowIsPaused(void);
310 void SetCaption (LPCSTR str) ;
311 void debug_output (const char *format, ...) ;
312 void PovMessageBox (const char *message, char *title) ;
313 int initialise_message_display (void) ;
314 void erase_display_window (HDC hdc, int xoffset, int yoffset) ;
315 void paint_display_window (HDC hdc) ;
316 void buffer_message (msgtype message_type, const char *s, bool addLF = false) ;
317 void buffer_stream_message (msgtype message_type, const char *s) ;
318 void clear_messages (bool print = true) ;
319 int update_message_display (lftype lf) ;
320 void message_printf (const char *format, ...) ;
321 void wrapped_printf (const char *format, ...) ;
322 void dump_pane_to_clipboard (void) ;
323 bool copy_text_to_clipboard(const char *text);
324 bool PutPrivateProfileInt (LPCSTR lpszSection, LPCSTR lpszEntry, UINT uiValue, LPCSTR lpszFilename) ;
325 void get_logfont (HDC hdc, LOGFONT *lf) ;
326 int create_message_font (HDC hdc, LOGFONT *lf) ;
327 void status_printf (int nSection, const char *format, ...) ;
328 void SetupExplorerDialog (HWND win) ;
329 char *findFirstPathSeparator (char *s) ;
330 char *findLastPathSeparator (char *s) ;
331 void appendPathSeparator (char *s) ;
332 bool hasTrailingPathSeparator (const char *s) ;
333 void trimTrailingPathSeparator (char *s) ;
334 void validatePath (char *s) ;
335 int joinPath (char *out, const char *path, const char *name) ;
336 void UpdateTabbedWindow (int current, bool force) ;
337 void CalculateClientWindows (bool redraw) ;
338 bool start_rendering (bool ignore_source_file) ;
339 bool HaveWin95 (void) ;
340 void render_stopped (void) ;
341 void cancel_render (void) ;
342 void SetStatusPanelItemText (int id, LPCSTR format, ...) ;
343 bool handle_main_command (WPARAM wParam, LPARAM lParam) ;
344 char *file_open (HWND hWnd) ;
345 bool OkToStopRendering (void);
346 bool reg_printf (bool useHKCU, char *keyName, char *valName, char *format, ...);
isPathSeparator(char c)347 static inline bool isPathSeparator (char c) { return (c == '\\' || c == '/'); }
348
349 // file PVMISC.C
350
351 FileType get_file_type (const char *filename) ;
352 bool is_non_primary_file(const char *filename) ;
353 void read_INI_settings (void) ;
354 void write_INI_settings (bool noreset = false) ;
355 void cloneOldIni(const std::string oldPath, const std::string newPath);
356 void update_menu_for_render (bool rendering) ;
357 void update_queue_status (bool write_files) ;
358 void draw_ordinary_listbox (DRAWITEMSTRUCT *d, bool fitpath) ;
359 void fill_statistics_listbox (HWND hlb, int id) ;
360 void resize_listbox_dialog (HWND hDlg, int idLb, int chars) ;
361 void CenterWindowRelative (HWND hRelativeTo, HWND hTarget, bool bRepaint, bool checkBorders) ;
362 void FitWindowInWindow (HWND hRelativeTo, HWND hTarget) ;
363 int splitfn (const char *filename, char *path, char *name, char *ext) ;
364 void splitpath (const char *filename, char *path, char *name) ;
365 bool process_toggles (WPARAM wParam) ;
366 void set_toggles (void) ;
367 void load_tool_menu (char *iniFilename) ;
368 char *parse_tool_command (char *command) ;
369 char *get_elapsed_time (int seconds) ;
370 void initialise_statusbar (bool isMaxiMiniMode) ;
371 void calculate_statusbar (void) ;
372 void paint_statusbar (int nSection) ;
373 void extract_ini_sections (char *filename, HWND hwnd) ;
374 void extract_ini_sections_ex (char *filename, HWND hwnd) ;
375 int select_combo_item_ex (HWND hwnd, char *s) ;
376 void paint_rendering_signal (int which_one) ;
377 char *get_full_name (char *s) ;
378 bool PovInvalidateRect (HWND hWnd, CONST RECT *lpRect, bool bErase) ;
379 int load_editors (char *iniFilename) ;
380 bool TaskBarAddIcon (HWND hwnd, UINT uID, HICON hicon, LPSTR lpszTip) ;
381 bool TaskBarModifyIcon (HWND hwnd, UINT uID, LPSTR lpszTip) ;
382 bool TaskBarDeleteIcon (HWND hwnd, UINT uID) ;
383 bool TestAccessAllowed (const char *Filename, unsigned int FileType, bool IsWrite) ;
384 char *clean (char *s) ;
385 bool fileExists (const char *filename) ;
386 bool dirExists (const char *filename) ;
387 bool GetDontShowAgain (const char *Name) ;
388 void PutDontShowAgain (const char *Name, bool dontShow) ;
389 void clear_dir_restrictions (void) ;
390 bool PutHKCU(const char *Section, const char *Name, const char *Value);
391 bool PutHKCU(const char *Section, const char *Name, const std::string& Value);
392 bool PutHKCU(const char *Section, const char *Name, unsigned Value);
393 unsigned GetHKCU(const char *Section, const char *Name, unsigned DefaultValue);
394 size_t GetHKCU(const char *Section, const char *Name, const char *DefaultValue, char *Buffer, unsigned MaxLength);
395 bool read_legacy_INI_settings (const char *iniFilename, const char *oldHome, const char *newHome);
396 void clone_legacy_dir_restrictions (const char *iniFilename, const char *oldHome, const char *newHome);
397
398 // file PVFILES.C
399
400 INT_PTR CALLBACK PovLegalDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) ;
401 char *save_demo_file (char *s1, char *s2) ;
402 void save_povlegal (void) ;
403
404 // file PVMENU.C
405
406 bool PVEnableMenuItem (UINT idItem, UINT state) ;
407 bool PVCheckMenuItem (UINT idItem, UINT state) ;
408 bool PVCheckMenuRadioItem (UINT idFirst, UINT idLast, UINT idItem) ;
409 bool PVModifyMenu (UINT idItem, UINT flags, UINT idNewItem, LPCSTR lpNewItem) ;
410 bool PVDeleteMenuItem (UINT idItem) ;
411 void init_menus (void) ;
412 void setup_menus (bool have_editor) ;
413 void clear_menu (HMENU hMenu) ;
414 void build_main_menu (HMENU hMenu, bool have_editor) ;
415 void build_editor_menu (HMENU hMenu) ;
416 void set_newuser_menus (bool hide) ;
417 void swap_renderwin_menu (void) ;
418 int find_menuitem (HMENU hMenu, LPCSTR title) ;
419
420 // file PVTEXT.C
421
422 void write_wrapped_text (HDC hdc, RECT *rect, const char *text) ;
423 void tip_of_the_day (HDC hdc, RECT *rect, char *text) ;
424 void paint_statusbar (int nSection) ;
425 void say_status_message (int section, const char *message) ;
426 void handle_menu_select (WPARAM wParam, LPARAM lParam) ;
427 char *clean_str (const char *s) ;
428 HWND create_toolbar (HWND hwndParent) ;
429 HWND create_tabbed_window (HWND hwndParent) ;
430 void initialise_tabbed_window (HWND hwnd) ;
431 unsigned add_window_to_tab (HWND hwnd, void *editor, char *s) ;
432 void resize_windows (unsigned left, unsigned top, unsigned width, unsigned height) ;
433 unsigned get_tab_index (HWND hwnd, void *editor) ;
434 char *preparse_commandline (char *s) ;
435 char *preparse_instance_commandline (char *s) ;
436 void add_edit_file (char *file);
437 char *extract_file (char *filename, char *s);
438 int need_hscroll (void) ;
439 HWND create_rebar (HWND hwndParent) ;
440 HWND CreateStatusbar (HWND hwndParent) ;
441 void ResizeStatusBar (HWND hwnd) ;
442 bool HandleStatusTooltip(NMHDR *nmh);
443
444 // file PVPOVMS.CPP
445
446 bool WIN_POVMS_Init (void) ;
447 void WIN_POVMS_Shutdown (void) ;
448
449 // file PVBITMAP.CPP
450
451 HDIB FAR BitmapToDIB (HBITMAP hBitmap, HPALETTE hPal);
452 HDIB FAR ChangeBitmapFormat (HBITMAP hBitmap,
453 WORD wBitCount,
454 DWORD dwCompression,
455 HPALETTE hPal);
456 HDIB FAR ChangeDIBFormat (HDIB hDIB, WORD wBitCount,
457 DWORD dwCompression);
458 HBITMAP FAR CopyScreenToBitmap (LPRECT);
459 HDIB FAR CopyScreenToDIB (LPRECT);
460 HBITMAP FAR CopyWindowToBitmap (HWND, WORD);
461 HDIB FAR CopyWindowToDIB (HWND, WORD);
462 HPALETTE FAR CreateDIBPalette (HDIB hDIB);
463 HDIB FAR CreateDIB(DWORD, DWORD, WORD);
464 WORD FAR DestroyDIB (HDIB);
465 void FAR DIBError (int ErrNo);
466 DWORD FAR DIBHeight (LPSTR lpDIB);
467 WORD FAR DIBNumColors (LPSTR lpDIB);
468 HBITMAP FAR DIBToBitmap (HDIB hDIB, HPALETTE hPal);
469 DWORD FAR DIBWidth (LPSTR lpDIB);
470 LPSTR FAR FindDIBBits (LPSTR lpDIB);
471 HPALETTE FAR GetSystemPalette (void);
472 HDIB FAR LoadDIB (LPSTR);
473 bool FAR PaintBitmap (HDC, LPRECT, HBITMAP, LPRECT, HPALETTE);
474 bool FAR PaintDIB (HDC, LPRECT, HDIB, LPRECT, HPALETTE);
475 int FAR PalEntriesOnDevice (HDC hDC);
476 WORD FAR PaletteSize (LPSTR lpDIB);
477 WORD FAR PrintDIB (HDIB, WORD, WORD, WORD, LPSTR);
478 WORD FAR PrintScreen (LPRECT, WORD, WORD, WORD, LPSTR);
479 WORD FAR PrintWindow (HWND, WORD, WORD, WORD, WORD, LPSTR);
480 WORD FAR SaveDIB (HDIB, LPSTR);
481 HANDLE AllocRoomForDIB(BITMAPINFOHEADER bi, HBITMAP hBitmap);
482 HBITMAP lpDIBToBitmap(void *lpDIBHdr, HPALETTE hPal);
483 HBITMAP lpDIBToBitmapAndPalette(void *lpDIBHdr);
484
485 // file PVUPDATE.CPP
486
487 bool InternetConnected(void);
488 int IsUpdateAvailable (bool SendSysinfo, char *CurrentVersion, std::string& NewVersion, std::string& Info);
489
490 #ifdef DECLARE_TABLES
491
492 // Default windows compatible halftone palette. This includes the default
493 // Windows system colors in the first 10 and last 10 entries in the
494 // palette.
495
496 RGBQUAD halftonePal [256] =
497 {
498 {0x00,0x00,0x00,0}, {0xA8,0x00,0x00,0}, {0x00,0xA8,0x00,0}, {0xA8,0xA8,0x00,0},
499 {0x00,0x00,0xA8,0}, {0xA8,0x00,0xA8,0}, {0x00,0x54,0xA8,0}, {0xA8,0xA8,0xA8,0},
500 {0x54,0x54,0x54,0}, {0xFC,0x54,0x54,0}, {0x54,0xFC,0x54,0}, {0xFC,0xFC,0x54,0},
501 {0x54,0x54,0xFC,0}, {0xFC,0x54,0xFC,0}, {0x54,0xFC,0xFC,0}, {0xFC,0xFC,0xFC,0},
502 {0x00,0x00,0x00,0}, {0x14,0x14,0x14,0}, {0x20,0x20,0x20,0}, {0x2C,0x2C,0x2C,0},
503 {0x00,0x00,0x00,0}, {0x00,0x00,0x33,0}, {0x00,0x00,0x66,0}, {0x00,0x00,0x99,0},
504 {0x00,0x00,0xCC,0}, {0x00,0x00,0xFF,0}, {0x00,0x33,0x00,0}, {0x00,0x33,0x33,0},
505 {0x00,0x33,0x66,0}, {0x00,0x33,0x99,0}, {0x00,0x33,0xCC,0}, {0x00,0x33,0xFF,0},
506 {0x00,0x66,0x00,0}, {0x00,0x66,0x33,0}, {0x00,0x66,0x66,0}, {0x00,0x66,0x99,0},
507 {0x00,0x66,0xCC,0}, {0x00,0x66,0xFF,0}, {0x00,0x99,0x00,0}, {0x00,0x99,0x33,0},
508 {0x00,0x99,0x66,0}, {0x00,0x99,0x99,0}, {0x00,0x99,0xCC,0}, {0x00,0x99,0xFF,0},
509 {0x00,0xCC,0x00,0}, {0x00,0xCC,0x33,0}, {0x00,0xCC,0x66,0}, {0x00,0xCC,0x99,0},
510 {0x00,0xCC,0xCC,0}, {0x00,0xCC,0xFF,0}, {0x00,0xFF,0x00,0}, {0x00,0xFF,0x00,0},
511 {0x00,0xFF,0x66,0}, {0x00,0xFF,0x99,0}, {0x00,0xFF,0xCC,0}, {0x00,0xFF,0xFF,0},
512 {0x33,0x00,0x00,0}, {0x33,0x00,0x33,0}, {0x33,0x00,0x66,0}, {0x33,0x00,0x99,0},
513 {0x33,0x00,0xCC,0}, {0x33,0x00,0xFF,0}, {0x33,0x33,0x00,0}, {0x33,0x33,0x33,0},
514 {0x33,0x33,0x66,0}, {0x33,0x33,0x99,0}, {0x33,0x33,0xCC,0}, {0x33,0x33,0xFF,0},
515 {0x33,0x66,0x00,0}, {0x33,0x66,0x33,0}, {0x33,0x66,0x66,0}, {0x33,0x66,0x99,0},
516 {0x33,0x66,0xCC,0}, {0x33,0x66,0xFF,0}, {0x33,0x99,0x00,0}, {0x33,0x99,0x33,0},
517 {0x33,0x99,0x66,0}, {0x33,0x99,0x99,0}, {0x33,0x99,0xCC,0}, {0x33,0x99,0xFF,0},
518 {0x33,0xCC,0x00,0}, {0x33,0xCC,0x33,0}, {0x33,0xCC,0x66,0}, {0x33,0xCC,0x99,0},
519 {0x33,0xCC,0xCC,0}, {0x33,0xCC,0xFF,0}, {0x00,0xFF,0x00,0}, {0x33,0xFF,0x33,0},
520 {0x33,0xFF,0x66,0}, {0x33,0xFF,0x99,0}, {0x33,0xFF,0xCC,0}, {0x33,0xFF,0xFF,0},
521 {0x66,0x00,0x00,0}, {0x66,0x00,0x33,0}, {0x66,0x00,0x66,0}, {0x66,0x00,0x99,0},
522 {0x66,0x00,0xCC,0}, {0x66,0x00,0xFF,0}, {0x66,0x33,0x00,0}, {0x66,0x33,0x33,0},
523 {0x66,0x33,0x66,0}, {0x66,0x33,0x99,0}, {0x66,0x33,0xCC,0}, {0x66,0x33,0xFF,0},
524 {0x66,0x66,0x00,0}, {0x66,0x66,0x33,0}, {0x66,0x66,0x66,0}, {0x66,0x66,0x99,0},
525 {0x66,0x66,0xCC,0}, {0x66,0x66,0xFF,0}, {0x66,0x99,0x00,0}, {0x66,0x99,0x33,0},
526 {0x66,0x99,0x66,0}, {0x66,0x99,0x99,0}, {0x66,0x99,0xCC,0}, {0x66,0x99,0xFF,0},
527 {0x66,0xCC,0x00,0}, {0x66,0xCC,0x33,0}, {0x66,0xCC,0x66,0}, {0x66,0xCC,0x99,0},
528 {0x66,0xCC,0xCC,0}, {0x66,0xCC,0xFF,0}, {0x66,0xFF,0x00,0}, {0x66,0xFF,0x33,0},
529 {0x66,0xFF,0x66,0}, {0x66,0xFF,0x99,0}, {0x66,0xFF,0xCC,0}, {0x66,0xFF,0xFF,0},
530 {0x99,0x00,0x00,0}, {0x99,0x00,0x33,0}, {0x99,0x00,0x66,0}, {0x99,0x00,0x99,0},
531 {0x99,0x00,0xCC,0}, {0x99,0x00,0xFF,0}, {0x99,0x33,0x00,0}, {0x99,0x33,0x33,0},
532 {0x99,0x33,0x66,0}, {0x99,0x33,0x99,0}, {0x99,0x33,0xCC,0}, {0x99,0x33,0xFF,0},
533 {0x99,0x66,0x00,0}, {0x99,0x66,0x33,0}, {0x99,0x66,0x66,0}, {0x99,0x66,0x99,0},
534 {0x99,0x66,0xCC,0}, {0x99,0x66,0xFF,0}, {0x99,0x99,0x00,0}, {0x99,0x99,0x33,0},
535 {0x99,0x99,0x66,0}, {0x99,0x99,0x99,0}, {0x99,0x99,0xCC,0}, {0x99,0x99,0xFF,0},
536 {0x99,0xCC,0x00,0}, {0x99,0xCC,0x33,0}, {0x99,0xCC,0x66,0}, {0x99,0xCC,0x99,0},
537 {0x99,0xCC,0xCC,0}, {0x99,0xCC,0xFF,0}, {0x99,0xFF,0x00,0}, {0x99,0xFF,0x33,0},
538 {0x99,0xFF,0x66,0}, {0x99,0xFF,0x99,0}, {0x99,0xFF,0xCC,0}, {0x99,0xFF,0xFF,0},
539 {0xCC,0x00,0x00,0}, {0xCC,0x00,0x33,0}, {0xCC,0x00,0x66,0}, {0xCC,0x00,0x99,0},
540 {0xCC,0x00,0xCC,0}, {0xCC,0x00,0xFF,0}, {0xCC,0x33,0x00,0}, {0xCC,0x33,0x33,0},
541 {0xCC,0x33,0x66,0}, {0xCC,0x33,0x99,0}, {0xCC,0x33,0xCC,0}, {0xCC,0x33,0xFF,0},
542 {0xCC,0x66,0x00,0}, {0xCC,0x66,0x33,0}, {0xCC,0x66,0x66,0}, {0xCC,0x66,0x99,0},
543 {0xCC,0x66,0xCC,0}, {0xCC,0x66,0xFF,0}, {0xCC,0x99,0x00,0}, {0xCC,0x99,0x33,0},
544 {0xCC,0x99,0x66,0}, {0xCC,0x99,0x99,0}, {0xCC,0x99,0xCC,0}, {0xCC,0x99,0xFF,0},
545 {0xCC,0xCC,0x00,0}, {0xCC,0xCC,0x33,0}, {0xCC,0xCC,0x66,0}, {0xCC,0xCC,0x99,0},
546 {0xCC,0xCC,0xCC,0}, {0xCC,0xCC,0xFF,0}, {0xCC,0xFF,0x00,0}, {0xCC,0xFF,0x33,0},
547 {0xCC,0xFF,0x66,0}, {0xCC,0xFF,0x99,0}, {0xCC,0xFF,0xCC,0}, {0xCC,0xFF,0xFF,0},
548 {0xFF,0x00,0x00,0}, {0xFF,0x00,0x00,0}, {0xFF,0x00,0x66,0}, {0xFF,0x00,0x99,0},
549 {0xFF,0x00,0xCC,0}, {0xFF,0x00,0xFF,0}, {0xFF,0x00,0x00,0}, {0xFF,0x33,0x33,0},
550 {0xFF,0x33,0x66,0}, {0xFF,0x33,0x99,0}, {0xFF,0x33,0xCC,0}, {0xFF,0x33,0xFF,0},
551 {0xFF,0x66,0x00,0}, {0xFF,0x66,0x33,0}, {0xFF,0x66,0x66,0}, {0xFF,0x66,0x99,0},
552 {0xFF,0x66,0xCC,0}, {0xFF,0x66,0xFF,0}, {0xFF,0x99,0x00,0}, {0xFF,0x99,0x33,0},
553 {0xFF,0x99,0x66,0}, {0xFF,0x99,0x99,0}, {0xFF,0x99,0xCC,0}, {0xFF,0x99,0xFF,0},
554 {0xFF,0xCC,0x00,0}, {0xFF,0xCC,0x33,0}, {0xFF,0xCC,0x66,0}, {0xFF,0xCC,0x99,0},
555 {0xFF,0xCC,0xCC,0}, {0xFF,0xCC,0xFF,0}, {0xFF,0xFF,0x00,0}, {0xFF,0xFF,0x33,0},
556 {0xFF,0xFF,0x66,0}, {0xFF,0xFF,0x99,0}, {0xFF,0xFF,0xCC,0}, {0xFF,0xFF,0xFF,0},
557 {0x2C,0x40,0x40,0}, {0x2C,0x40,0x3C,0}, {0x2C,0x40,0x34,0}, {0x2C,0x40,0x30,0},
558 {0x2C,0x40,0x2C,0}, {0x30,0x40,0x2C,0}, {0x34,0x40,0x2C,0}, {0x3C,0x40,0x2C,0},
559 {0x40,0x40,0x2C,0}, {0x40,0x3C,0x2C,0}, {0x40,0x34,0x2C,0}, {0x40,0x30,0x2C,0},
560 {0x54,0x54,0x54,0}, {0xFC,0x54,0x54,0}, {0x54,0xFC,0x54,0}, {0xFC,0xFC,0x54,0},
561 {0x54,0x54,0xFC,0}, {0xFC,0x54,0xFC,0}, {0x54,0xFC,0xFC,0}, {0xFC,0xFC,0xFC,0}
562 } ;
563
564 // Division lookup tables. These tables compute 0-255 divided by 51 and
565 // modulo 51. These tables could approximate gamma correction.
566
567 uchar div51 [256] =
568 {
569 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
570 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
571 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
572 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
573 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
574 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
575 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
576 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
577 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
578 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
579 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5
580 } ;
581
582 uchar mod51 [256] =
583 {
584 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
585 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
586 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6,
587 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
588 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
589 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
590 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
591 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
592 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
593 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
594 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3,
595 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
596 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
597 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0
598 } ;
599
600 // Multiplication lookup tables. These compute 0-5 times 6 and 36.
601
602 uchar mul6 [6] = {0, 6, 12, 18, 24, 30} ;
603 uchar mul36 [6] = {0, 36, 72, 108, 144, 180} ;
604
605 // Ordered 8x8 dither matrix for 8 bit to 2.6 bit halftones.
606
607 uchar dither8x8 [64] =
608 {
609 0, 38, 9, 47, 2, 40, 11, 50,
610 25, 12, 35, 22, 27, 15, 37, 24,
611 6, 44, 3, 41, 8, 47, 5, 43,
612 31, 19, 28, 15, 34, 21, 31, 18,
613 1, 39, 11, 49, 0, 39, 10, 48,
614 27, 14, 36, 23, 26, 13, 35, 23,
615 7, 46, 4, 43, 7, 45, 3, 42,
616 33, 20, 30, 17, 32, 19, 29, 16,
617 } ;
618
619 #endif // #if DECLARE_TABLES
620
621 }
622
623 #endif // PVENGINE_H_INCLUDED
624
625