PixelLightAPI  .
ImageToolsWindows.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: ImageToolsWindows.h                            *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLGRAPHICS_IMAGETOOLS_WINDOWS_H__
00024 #define __PLGRAPHICS_IMAGETOOLS_WINDOWS_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/PLCore.h>
00032 #include <PLCore/PLCoreWindowsIncludes.h>
00033 #include "PLGraphics/PLGraphics.h"
00034 
00035 
00036 //[-------------------------------------------------------]
00037 //[ Namespace                                             ]
00038 //[-------------------------------------------------------]
00039 namespace PLGraphics {
00040 
00041 
00042 //[-------------------------------------------------------]
00043 //[ Forward declarations                                  ]
00044 //[-------------------------------------------------------]
00045 class Image;
00046 
00047 
00048 //[-------------------------------------------------------]
00049 //[ Classes                                               ]
00050 //[-------------------------------------------------------]
00051 /**
00052 *  @brief
00053 *    Static class with some useful Windows image tools
00054 */
00055 class ImageToolsWindows {
00056 
00057 
00058     //[-------------------------------------------------------]
00059     //[ Public functions                                      ]
00060     //[-------------------------------------------------------]
00061     public:
00062         /**
00063         *  @brief
00064         *    Returns a Windows-friendly bitmap handle
00065         *
00066         *  @param[in] cImage
00067         *    Image to use
00068         *  @param[in] hDC
00069         *    The device context that you want to receive the HBITMAP
00070         *
00071         *  @return
00072         *    Windows-friendly bitmap handle
00073         *
00074         *  @note
00075         *    - Creates a Windows bitmap handle (HBITMAP) copy of the current image, for
00076         *      direct use in Windows
00077         *    - Use the windows function DeleteObject() to free the bitmap
00078         */
00079         static PLGRAPHICS_API HBITMAP ConvertToHBitmap(Image &cImage, HDC hDC);
00080 
00081         /**
00082         *  @brief
00083         *    Sets the current image to be a copy of a Windows bitmap
00084         *
00085         *  @param[in] cImage
00086         *    Image to use
00087         *  @param[in] hBitmap
00088         *    Bitmap to copy to the given image
00089         *
00090         *  @return
00091         *    'true' if all went fine, else 'false'
00092         *
00093         *  @remarks
00094         *    Copies hBitmap to the given image in a 'normal' format we can
00095         *    understand. The image can then be used just as if you had loaded an image
00096         *    via Image::Load(). This function is the opposite of ConvertToHBitmap().
00097         */
00098         static PLGRAPHICS_API bool SetHBitmap(Image &cImage, HBITMAP hBitmap);
00099 
00100         /**
00101         *  @brief
00102         *    Copies the Windows clipboard to the current image
00103         *
00104         *  @param[in] cImage
00105         *    Image to use
00106         *
00107         *  @return
00108         *    'true' if all went fine, else 'false'
00109         *
00110         *  @remarks
00111         *    Copies the contents of the Windows clipboard into the given image,
00112         *    resizing as necessary.
00113         */
00114         static PLGRAPHICS_API bool GetWinClipboard(Image &cImage);
00115 
00116         /**
00117         *  @brief
00118         *    Copies an image to the Windows clipboard
00119         *
00120         *  @param[in] cImage
00121         *    Image to use
00122         *
00123         *  @return
00124         *    'true' if all went fine, else 'false'
00125         *
00126         *  @return
00127         *    Copies the given image to the Windows clipboard
00128         */
00129         static PLGRAPHICS_API bool SetWinClipboard(Image &cImage);
00130 
00131         /**
00132         *  @brief
00133         *    Loads a Windows resource as the current image
00134         *
00135         *  @param[in] cImage
00136         *    Image to use
00137         *  @param[in] hInst
00138         *    The application's HINSTANCE
00139         *  @param[in] nID
00140         *    The resource identifier of the resource to be loaded
00141         *  @param[in] sResourceType
00142         *    The type of user-defined resource (name used when creating)
00143         *  @param[in] sFileType
00144         *    The type of image to be loaded, e.g. "bmp". Pass empty string
00145         *    to let the type be determined automatically
00146         *
00147         *  @return
00148         *   'true' if all went fine, else 'false'
00149         *
00150         *  @remarks
00151         *    Windows-specific function that loads a resource as the given image.
00152         *    This feature allows you to have images directly in your .exe and not worry
00153         *    whether a particular file is present on the user's hard drive.
00154         */
00155         static PLGRAPHICS_API bool LoadResource(Image &cImage, HINSTANCE hInst, int nID, const PLCore::String &sResourceType, const PLCore::String &sFileType);
00156 
00157 
00158     //[-------------------------------------------------------]
00159     //[ Private functions                                     ]
00160     //[-------------------------------------------------------]
00161     private:
00162         /**
00163         *  @brief
00164         *    Convert a 32 bit image with alpha map to a window HBITMAP
00165         *
00166         *  @param[in] cImage
00167         *    Image to use
00168         *  @param[in] hDC
00169         *    The device context that you want to receive the HBITMAP
00170         *
00171         *  @return
00172         *    Windows-friendly bitmap handle
00173         *
00174         *  @note
00175         *    - This function is used to convert 32 bit images with RGBA data, because
00176         *      the devil function strips the A information from the data
00177         */
00178         static HBITMAP PLConvertToHBitmap(Image &cImage, HDC hDC);
00179 
00180 
00181 };
00182 
00183 
00184 //[-------------------------------------------------------]
00185 //[ Namespace                                             ]
00186 //[-------------------------------------------------------]
00187 } // PLGraphics
00188 
00189 
00190 #endif // __PLGRAPHICS_IMAGETOOLS_WINDOWS_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:50:57
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported