PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: ImageToolsWindows.h * 00003 * 00004 * Copyright (C) 2002-2012 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/PLCoreWindowsIncludes.h> 00032 #include "PLGraphics/PLGraphics.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLGraphics { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Forward declarations ] 00043 //[-------------------------------------------------------] 00044 class Image; 00045 00046 00047 //[-------------------------------------------------------] 00048 //[ Classes ] 00049 //[-------------------------------------------------------] 00050 /** 00051 * @brief 00052 * Static class with some useful Windows image tools 00053 */ 00054 class ImageToolsWindows { 00055 00056 00057 //[-------------------------------------------------------] 00058 //[ Public functions ] 00059 //[-------------------------------------------------------] 00060 public: 00061 /** 00062 * @brief 00063 * Returns a Windows-friendly bitmap handle 00064 * 00065 * @param[in] cImage 00066 * Image to use 00067 * @param[in] hDC 00068 * The device context that you want to receive the HBITMAP 00069 * 00070 * @return 00071 * Windows-friendly bitmap handle 00072 * 00073 * @note 00074 * - Creates a Windows bitmap handle (HBITMAP) copy of the current image, for 00075 * direct use in Windows 00076 * - Use the windows function DeleteObject() to free the bitmap 00077 */ 00078 static PLGRAPHICS_API HBITMAP ConvertToHBitmap(Image &cImage, HDC hDC); 00079 00080 /** 00081 * @brief 00082 * Sets the current image to be a copy of a Windows bitmap 00083 * 00084 * @param[in] cImage 00085 * Image to use 00086 * @param[in] hBitmap 00087 * Bitmap to copy to the given image 00088 * 00089 * @return 00090 * 'true' if all went fine, else 'false' 00091 * 00092 * @remarks 00093 * Copies hBitmap to the given image in a 'normal' format we can 00094 * understand. The image can then be used just as if you had loaded an image 00095 * via Image::Load(). This function is the opposite of ConvertToHBitmap(). 00096 */ 00097 static PLGRAPHICS_API bool SetHBitmap(Image &cImage, HBITMAP hBitmap); 00098 00099 /** 00100 * @brief 00101 * Copies the Windows clipboard to the current image 00102 * 00103 * @param[in] cImage 00104 * Image to use 00105 * 00106 * @return 00107 * 'true' if all went fine, else 'false' 00108 * 00109 * @remarks 00110 * Copies the contents of the Windows clipboard into the given image, 00111 * resizing as necessary. 00112 */ 00113 static PLGRAPHICS_API bool GetWinClipboard(Image &cImage); 00114 00115 /** 00116 * @brief 00117 * Copies an image to the Windows clipboard 00118 * 00119 * @param[in] cImage 00120 * Image to use 00121 * 00122 * @return 00123 * 'true' if all went fine, else 'false' 00124 * 00125 * @return 00126 * Copies the given image to the Windows clipboard 00127 */ 00128 static PLGRAPHICS_API bool SetWinClipboard(Image &cImage); 00129 00130 /** 00131 * @brief 00132 * Loads a Windows resource as the current image 00133 * 00134 * @param[in] cImage 00135 * Image to use 00136 * @param[in] hInst 00137 * The application's HINSTANCE 00138 * @param[in] nID 00139 * The resource identifier of the resource to be loaded 00140 * @param[in] sResourceType 00141 * The type of user-defined resource (name used when creating) 00142 * @param[in] sFileType 00143 * The type of image to be loaded, e.g. "bmp". Pass empty string 00144 * to let the type be determined automatically 00145 * 00146 * @return 00147 * 'true' if all went fine, else 'false' 00148 * 00149 * @remarks 00150 * Windows-specific function that loads a resource as the given image. 00151 * This feature allows you to have images directly in your .exe and not worry 00152 * whether a particular file is present on the user's hard drive. 00153 */ 00154 static PLGRAPHICS_API bool LoadResource(Image &cImage, HINSTANCE hInst, int nID, const PLCore::String &sResourceType, const PLCore::String &sFileType); 00155 00156 00157 //[-------------------------------------------------------] 00158 //[ Private functions ] 00159 //[-------------------------------------------------------] 00160 private: 00161 /** 00162 * @brief 00163 * Convert a 32 bit image with alpha map to a window HBITMAP 00164 * 00165 * @param[in] cImage 00166 * Image to use 00167 * @param[in] hDC 00168 * The device context that you want to receive the HBITMAP 00169 * 00170 * @return 00171 * Windows-friendly bitmap handle 00172 * 00173 * @note 00174 * - This function is used to convert 32 bit images with RGBA data, because 00175 * the devil function strips the A information from the data 00176 */ 00177 static HBITMAP PLConvertToHBitmap(Image &cImage, HDC hDC); 00178 00179 00180 }; 00181 00182 00183 //[-------------------------------------------------------] 00184 //[ Namespace ] 00185 //[-------------------------------------------------------] 00186 } // PLGraphics 00187 00188 00189 #endif // __PLGRAPHICS_IMAGETOOLS_WINDOWS_H__
|