# zoom_func.h

Go to the documentation of this file.

    00001 /* $Id: zoom_func.h 18354 2009-11-30 23:59:42Z rubidium $ */
    00002
    00005 #ifndef ZOOM_FUNC_H
    00006 #define ZOOM_FUNC_H
    00007
    00008 #include "zoom_type.h"
    00009
    00017 static inline int ScaleByZoom(int value, ZoomLevel zoom)
    00018 {
    00019   if (zoom == ZOOM_LVL_NORMAL) return value;
    00020   int izoom = zoom - ZOOM_LVL_NORMAL;
    00021   return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : (value + (1 << -izoom) - 1) >> -izoom;
    00022 }
    00023
    00031 static inline int UnScaleByZoom(int value, ZoomLevel zoom)
    00032 {
    00033   if (zoom == ZOOM_LVL_NORMAL) return value;
    00034   int izoom = zoom - ZOOM_LVL_NORMAL;
    00035   return (zoom > ZOOM_LVL_NORMAL) ? (value + (1 << izoom) - 1) >> izoom : value << -izoom;
    00036 }
    00037
    00044 static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
    00045 {
    00046   if (zoom == ZOOM_LVL_NORMAL) return value;
    00047   int izoom = zoom - ZOOM_LVL_NORMAL;
    00048   return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> -izoom;
    00049 }
    00050
    00057 static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
    00058 {
    00059   if (zoom == ZOOM_LVL_NORMAL) return value;
    00060   int izoom = zoom - ZOOM_LVL_NORMAL;
    00061   return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << -izoom;
    00062 }
    00063
    00064 #endif /* ZOOM_FUNC_H */