#include "bmpprefs.h"
#include "bmpsrc.h"
#include "filtimop.h"
Go to the source code of this file.
Classes | |
class | BitmapImportOptions |
Base class for storing import options It's not actually used much though... More... | |
class | BaseBitmapFilter |
Base class for bitmap filters. (Currently export only). Inherited classes tend to be in the OIL layer. The base class fails on both imports & exports, so you only need to override the half that you implement. More... | |
Functions | |
INT32 | GridLock (INT32 Position, INT32 GridSize) |
Grid-locks a given plotting position to lie over a grid (usually the output device-pixel grid). The result is shifted by half the grid size to grid-lock to the _center_ of a pixel rather than the edges. Note: stolen from ColourEditDlg/PreviewDialog rendering routines Hoisted into header file, since useful for anything that uses bitmaps. |
|
Grid-locks a given plotting position to lie over a grid (usually the output device-pixel grid). The result is shifted by half the grid size to grid-lock to the _center_ of a pixel rather than the edges. Note: stolen from ColourEditDlg/PreviewDialog rendering routines Hoisted into header file, since useful for anything that uses bitmaps.
Definition at line 541 of file bitfilt.h. 00542 { 00543 // By truncating down to the nearest grid point, and adding half the grid value, 00544 // we achieve rounding to the nearest offset-grid position. 00545 00546 // NOTE: 00547 // The original algorithm incorrectly rounded negative numbers towards 00548 // zero. Negative numbers should be rounded towards negative infinity. 00549 // The algorithm has been corrected by always rounding a positive number 00550 // and restoring the original sign of the number after rounding. 00551 00552 BOOL bNegative = FALSE; // Assume the number is positive 00553 00554 if (Position < 0) // If the number if not positive 00555 { // note the fact and make positive 00556 bNegative = TRUE; 00557 Position = -Position; 00558 } 00559 00560 Position += GridSize / 2; 00561 Position -= Position % GridSize; 00562 00563 if (bNegative) // If the number was negative 00564 Position = -Position; // restore the sign 00565 00566 return (Position); 00567 }
|