1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
-----------------------------------------------------------------------------
-- |
-- Module : Graphics.UI.SDL.Rotozoomer
-- Copyright : (c) David Himmelstrup 2005
-- License : BSD-like
--
-- Maintainer : lemmih@gmail.com
-- Stability : provisional
-- Portability : portable
--
-----------------------------------------------------------------------------
module Graphics.UI.SDL.Rotozoomer where
import Foreign
import Foreign.C
import Graphics.UI.SDL.Video
import Graphics.UI.SDL.General
import Graphics.UI.SDL.Types
finalizeWhenNotNull :: String -> Ptr SurfaceStruct -> IO Surface
finalizeWhenNotNull errMsg image
= if image == nullPtr
then failWithError errMsg
else mkFinalizedSurface image
-- SDL_Surface * rotozoomSurface (SDL_Surface *src, double angle, double zoom, int smooth);
foreign import ccall unsafe "rotozoomSurface" sdlRotozoom
:: Ptr SurfaceStruct -> Double -> Double -> Int -> IO (Ptr SurfaceStruct)
rotozoom :: Surface -> Double -> Double -> Bool -> IO Surface
rotozoom src angle zoom smooth
= withForeignPtr src $ \imgSrc ->
sdlRotozoom imgSrc angle zoom (fromBool smooth) >>= finalizeWhenNotNull "rotozoomSurface"
{-
-- SDL_Surface * rotozoomSurfaceXY (SDL_Surface *src, double angle, double zoomx, double zoomy, int smooth);
foreign import ccall unsafe "rotozoomSurfaceXY" sdlRotozoomXY
:: Ptr SurfaceStruct -> Double -> Double -> Double -> Int -> IO (Ptr SurfaceStruct)
rotozoomXY :: Surface -> Double -> Double -> Double -> Bool -> IO Surface
rotozoomXY src angle zoomx zoomy smooth
= withForeignPtr src $ \imgSrc ->
sdlRotozoomXY imgSrc angle zoomx zoomy (fromBool smooth) >>= finalizeWhenNotNull "rotozoomSurfaceXY"
-}
-- SDL_Surface * zoomSurface (SDL_Surface *src, double zoomx, double zoomy, int smooth);
foreign import ccall unsafe "zoomSurface" sdlZoom
:: Ptr SurfaceStruct -> Double -> Double -> Int -> IO (Ptr SurfaceStruct)
zoom :: Surface -> Double -> Double -> Bool -> IO Surface
zoom src zoomx zoomy smooth
= withForeignPtr src $ \imgSrc ->
sdlZoom imgSrc zoomx zoomy (fromBool smooth) >>= finalizeWhenNotNull "zoomSurface"
|