[PR]

水無瀬の部屋 > Programming > sample > exe2ico > rsrc2bmp.cpp
最終更新日: 2007/03/16

   1: //*********************************************************
   2: // プロジェクト: exe2ico
   3: //  ファイル名: rsrc2bmp.cpp
   4: //*********************************************************
   5: #include "rsrc2bmp.h"
   6: #include "util.h"
   7: #include <filefmt/bmpfile.h>
   8: 
   9: 
  10: //*********************************************************
  11: // rsrc2bmp
  12: //*********************************************************
  13: size_t
  14: CALLBACK
  15: rsrc2bmp
  16: 	(
  17: 		      BYTE    *buf,
  18: 		      size_t   bufsize,
  19: 		      HMODULE  hModule,
  20: 		const char    *name,
  21: 		const char    *type
  22: 	)
  23: {
  24: 	// パラメタの仮定
  25: 	ASSERT( IsValidInstanceHandle( hModule ) );
  26: 	ASSERT( IsValidResourceName( name ) );
  27: 	ASSERT( IsValidResourceName( type ) );
  28: 	ASSERT(  buf || (0 == bufsize) );
  29: 	ASSERT( !buf || IsValidPtr( buf, bufsize ) );
  30: 	ASSERT( !buf || (DESTROY_BUFFER( buf, bufsize ), true) ); // [破壊]
  31: 
  32: 	//
  33: 	size_t size = 0;
  34: 
  35: 	//
  36: 	const void *src = GetResourcePtr( hModule, name, type );
  37: 	if ( src )
  38: 	{		
  39: 		const BITMAPINFOHEADER *bih = static_cast<const BITMAPINFOHEADER *>( src );
  40: 		if ( (BI_RGB == bih->biCompression)
  41: 		  && (     1 == bih->biPlanes) )
  42: 		{
  43: 			size = CalcBitmapFileSize( bih );
  44: 
  45: 			if ( buf )
  46: 			{			
  47: 				BITMAPFILEHEADER bfh;
  48: 				MakeBitmapFileHeader( &bfh, bih );
  49: 				memmove( buf,                 &bfh, sizeof( bfh ) );
  50: 				memmove( buf + sizeof( bfh ), src,  size - sizeof( bfh ) );
  51: 			}
  52: 		}
  53: 	}
  54: 
  55: 	ASSERT( !buf || (size <= bufsize) );
  56: 	ASSERT( !buf
  57: 		|| (size    == rsrc2bmp( null, 0, hModule, name, type ))
  58: 		|| (bufsize <= rsrc2bmp( null, 0, hModule, name, type )) );
  59: 	return size;
  60: }//rsrc2bmp
  61: 
  62: 
  63: //** end **

参照:


Google
ご意見・ご感想をお聞かせ下さい。匿名で送信できます。

 * 返信が必要な場合には postmaster@katsura-kotonoha.sakura.ne.jp へ直接メールしてください。

水無瀬の部屋 > sample > exe2ico > rsrc2bmp.cpp

このページは cpp2web が出力しました。
水無瀬 優 postmaster@katsura-kotonoha.sakura.ne.jp
http://katsura-kotonoha.sakura.ne.jp/prog/code/exe2ico/rsrc2bmp_cpp.shtml
同人ダウンロード販売
同人ダウンロード販売|DL.Getchu.com