예제 #1
0
//登録名・ファイルのパス・フォントの名前を指定
//ex ("HG96", "hoge.ttf", "Hogeman's_Font", 96, 5)
void Font::LoadFont(std::string reg_name, std::string file_path, std::string font_name, int fontsize, int thick){

	file_path = "Fonts/" + file_path;
	const char* filename = file_path.c_str();

	// ファイルのサイズを得る
	int FontFileSize = FileRead_size(filename);
	// フォントファイルを開く
	int FontFileHandle = FileRead_open(filename);
	// フォントデータ格納用のメモリ領域を確保
	void *Buffer = malloc(FontFileSize);
	// フォントファイルを丸ごとメモリに読み込む
	FileRead_read(Buffer, FontFileSize, FontFileHandle);
	// AddFontMemResourceEx引数用
	DWORD font_num = 0;
	// メモリに読み込んだフォントデータをシステムに追加
	if (AddFontMemResourceEx(Buffer, FontFileSize, NULL, &font_num) != 0){}
	else
	{
		// フォント読込エラー処理
		MessageBox(NULL, "フォント読込失敗", "", MB_OK);
	}

	int tmp_handle = CreateFontToHandle(font_name.c_str(), fontsize, thick, DX_FONTTYPE_ANTIALIASING_4X4);
	handlemap.emplace(reg_name.c_str(), tmp_handle);
}
	Effekseer::FileReader* OpenRead( const EFK_CHAR* path ) 
	{
		auto path_ = ToMulti((wchar_t*)path);
		
		auto fileHandle = g_openFunc(path_.c_str());

		if(fileHandle == 0) return 0;
		
		auto size = g_readSizeFunc(path_.c_str());
		std::vector<uint8_t> data;
		data.resize(size);
		FileRead_read(data.data(), size, fileHandle);
		FileRead_close(fileHandle);

		return new EffekseerFileReader(data);
	}
예제 #3
0
파일: loadgraph.c 프로젝트: yreeen/dxlibp
static DXPTEXTURE3* LoadPngImage(const char *FileName)
{
	u32 filesize;
	int fp = -1;
	DXPPNG png;
	DXPPNG_PARAMS params;
	void *buf = NULL;
	DXPTEXTURE3 *texptr = NULL;
	filesize = FileRead_size(FileName);
	if(!filesize)goto err;
	buf = malloc(filesize);
	if(!buf)goto err;
	texptr = dxpGraphicsCreateTexture();
	if(!texptr)goto err;
	fp = FileRead_open(FileName,0);
	if(fp == 0)goto err;
	FileRead_read(buf,filesize,fp);
	FileRead_close(fp);
	params.funcs.pmalloc = malloc;
	params.funcs.pmemalign = memalign;
	params.funcs.pfree = free;
	params.mode = DXPPNG_MODE_GPU;
	params.src = buf;
	params.srcLength = filesize;
	if(dxppng_decode(&params,&png) == -1)goto err;
	texptr->alphabit = png.alpha ? 1 : 0;
	texptr->colorkey = dxpGraphicsData.colorkey;
	texptr->width = png.widthN2;
	texptr->height = png.heightN2;
	texptr->pitch = png.pitch;
	texptr->ppalette = (u32 *)png.clut;
	texptr->psm = png.psm;
	texptr->reloadflag = 1;
	texptr->size2_nflag = (png.height == png.heightN2 && png.width == png.widthN2 ? 1 : 0);
	texptr->swizzledflag = 0;
	texptr->texdata = png.raw;
	texptr->texvram = 0;
	texptr->umax = png.width;
	texptr->vmax = png.height;
	return texptr;
err:
	FileRead_close(fp);
	free(buf);
	dxpGraphicsReleseTexture(texptr);
	return NULL;
}
예제 #4
0
bool Client::load( ) {
	int fh = FileRead_open( "IP.ini" );
	if ( fh == 0 ) {
		return false;
	}

	IPDATA ip;
	if ( FileRead_read( &ip, sizeof( IPDATA ), fh ) == -1 ) {
		FileRead_close( fh ) ;
		return false;
	}

	_ip[ 0 ] = ip.d1;
	_ip[ 1 ] = ip.d2;
	_ip[ 2 ] = ip.d3;
	_ip[ 3 ] = ip.d4;

    FileRead_close( fh ) ;
	return true;
}
예제 #5
0
파일: ogg.c 프로젝트: mafu9/dxlibp-kai
static size_t ogg_read_func(void *ptr, size_t size, size_t nmemb, void *datasource)
{
	int fh = *(int*)datasource;
	return (size_t)FileRead_read(ptr,(int)(size*nmemb),fh);
}