<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>ImageStone: ImageHandle_IPicture.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.1 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a></div>
<h1>ImageHandle_IPicture.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
00002 <span class="comment"> * Copyright (C) =USTC= Fu Li</span>
00003 <span class="comment"> *</span>
00004 <span class="comment"> * Author : Fu Li</span>
00005 <span class="comment"> * Create : 2005-9-12</span>
00006 <span class="comment"> * Home : http://www.crazy-bit.com/</span>
00007 <span class="comment"> * Mail : crazybit@263.net</span>
00008 <span class="comment"> * History : </span>
00009 <span class="comment"> */</span>
00010 <span class="preprocessor">#ifndef __PCL_IMAGE_HANDLE_IPICTURE__2005_09_12__H__</span>
00011 <span class="preprocessor"></span><span class="preprocessor">#define __PCL_IMAGE_HANDLE_IPICTURE__2005_09_12__H__</span>
00012 <span class="preprocessor"></span><span class="preprocessor">#include "ImageHandleBase.h"</span>
00013
00014 <span class="comment">//class FCImageHandle ;</span>
00015 <span class="keyword">class </span><a class="code" href="class_f_c_image_handle___i_picture.html">FCImageHandle_IPicture</a> ;
00016
00017 <span class="comment">//=============================================================================</span>
<a name="l00021"></a><a class="code" href="class_f_c_image_handle___i_picture.html">00021</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="class_f_c_image_handle___i_picture.html">FCImageHandle_IPicture</a> : <span class="keyword">public</span> <a class="code" href="class_f_c_image_handle.html">FCImageHandle</a>
00022 {
00023 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="class_f_c_image_handle_base.html#a1">LoadImageMemory</a> (<span class="keyword">const</span> BYTE* pStart, <span class="keywordtype">int</span> nFileSize)
00024 {
00025 <span class="keywordflow">if</span> (!pStart || (nFileSize <= 0))
00026 <span class="keywordflow">return</span> false ;
00027
00028 HGLOBAL hBuffer = ::GlobalAlloc (GMEM_MOVEABLE, nFileSize) ;
00029
00030 <span class="comment">// copy buffer to HGLOBAL</span>
00031 ::CopyMemory (::GlobalLock(hBuffer), pStart, nFileSize) ;
00032 ::GlobalUnlock (hBuffer) ;
00033
00034 IStream * pStream = NULL ;
00035 IPicture * pIPic = NULL ;
00036 <a class="code" href="class_f_c_obj_image.html">FCObjImage</a> * pImg = <span class="keyword">new</span> <a class="code" href="class_f_c_obj_image.html">FCObjImage</a> ;
00037 <span class="keywordflow">if</span> (::CreateStreamOnHGlobal (hBuffer, TRUE, &pStream) == S_OK)
00038 {
00039 <span class="keywordflow">if</span> (::OleLoadPicture (pStream, nFileSize, FALSE, IID_IPicture, (LPVOID*)&pIPic) == S_OK)
00040 {
00041 OLE_HANDLE hDDB ;
00042 pIPic->get_Handle (&hDDB) ;
00043
00044 BITMAP bm ;
00045 GetObject ((HGDIOBJ)hDDB, <span class="keyword">sizeof</span>(BITMAP), &bm) ;
00046 <span class="keywordflow">if</span> (pImg-><a class="code" href="class_f_c_obj_image.html#z27_0">Create</a> (bm.bmWidth, bm.bmHeight, 24))
00047 {
00048 <span class="comment">// dest format</span>
00049 <a class="code" href="class_p_c_l__array.html">PCL_array<BITMAPINFO></a> bmfh (pImg-><a class="code" href="class_f_c_obj_image.html#z29_8">NewImgInfoWithPalette</a>()) ;
00050 HDC hdc = ::GetDC(NULL) ;
00051 ::GetDIBits (hdc, (HBITMAP)hDDB, 0, bm.bmHeight, pImg-><a class="code" href="class_f_c_obj_image.html#z29_3">GetMemStart</a>(), bmfh.get(), DIB_RGB_COLORS) ;
00052 ::ReleaseDC (NULL, hdc) ;
00053 }
00054 pIPic->Release() ;
00055 }
00056 pStream->Release() ;
00057 }
00058
00059 <span class="keywordflow">if</span> (!pImg-><a class="code" href="class_f_c_obj_image.html#z29_0">IsValidImage</a>())
00060 {
00061 <span class="keyword">delete</span> pImg; <span class="keywordflow">return</span> <span class="keyword">false</span>;
00062 }
00063 <a class="code" href="class_p_c_l___interface___composite.html#a2">PCL_PushObject</a> (pImg) ; <span class="comment">// pImg's ownership</span>
00064 <span class="keywordflow">return</span> true ;
00065 }
00066 };
00067
00068 <span class="comment">//=============================================================================</span>
00069 <span class="comment">// inline Implement</span>
00070 <span class="comment">//=============================================================================</span>
00071
00072 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Wed Mar 8 11:12:46 2006 for ImageStone by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.1 </small></address>
</body>
</html>