# zoom_func.h

    00001 /* $Id: zoom_func.h 11914 2008-01-18 03:48:29Z glx $ */
    00002
    00005 #ifndef ZOOM_FUNC_H
    00006 #define ZOOM_FUNC_H
    00007
    00008 #include "zoom_type.h"
    00009
    00010 extern ZoomLevel _saved_scrollpos_zoom;
    00011
    00019 static inline int ScaleByZoom(int value, ZoomLevel zoom)
    00020 {
    00021   if (zoom == ZOOM_LVL_NORMAL) return value;
    00022   int izoom = zoom - ZOOM_LVL_NORMAL;
    00023   return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : (value + (1 << -izoom) - 1) >> -izoom;
    00024 }
    00025
    00033 static inline int UnScaleByZoom(int value, ZoomLevel zoom)
    00034 {
    00035   if (zoom == ZOOM_LVL_NORMAL) return value;
    00036   int izoom = zoom - ZOOM_LVL_NORMAL;
    00037   return (zoom > ZOOM_LVL_NORMAL) ? (value + (1 << izoom) - 1) >> izoom : value << -izoom;
    00038 }
    00039
    00046 static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
    00047 {
    00048   if (zoom == ZOOM_LVL_NORMAL) return value;
    00049   int izoom = zoom - ZOOM_LVL_NORMAL;
    00050   return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> -izoom;
    00051 }
    00052
    00059 static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
    00060 {
    00061   if (zoom == ZOOM_LVL_NORMAL) return value;
    00062   int izoom = zoom - ZOOM_LVL_NORMAL;
    00063   return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << -izoom;
    00064 }
    00065
    00066 #endif /* ZOOM_FUNC_H */