⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 l_allbmp.cpp

📁 网页游戏赤壁
💻 CPP
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>
//#include <stat.h>
//#include <types.h>
#include <fcntl.h>

#include  "stdafx.h"
#include  "ddapi.h"
#include "L_allbmp.h"
#include "DDCompo.h"	// direct draw object
#include "Assert.h"	// ErrorMessage(), Assert()
#include "CBMain.h"	

#define DD_DEBUG

void CPicture_imageall::image_open_compress (char compress_file_name[20])
{
   // int   handle,compress_bytes;
	/*
    handle=open (compress_file_name,O_RDONLY|O_BINARY);

    if (handle!=-1)
       compress_bytes=filelength (handle);
	*/
    if ((compress_file=fopen (compress_file_name,"rb"))==NULL)
    {
		printf ("This file no find !!!");
		exit (1);
    }
	/*
    close ( handle );
	
    if ((compress_buf=new char [compress_bytes])==NULL)
    {
		printf("Memory out !!!");
		exit (2);
    }
    fread (compress_buf,1,compress_bytes,compress_file);
	*/
}

void CPicture_imageall::image_close_compress (void)
{
    fclose ( compress_file );
}

void CPicture_imageall::image_open_index (char index_file_name[20])
{
    int   handle,index_bytes;
    handle=open (index_file_name,O_RDONLY);

    if (handle!=-1)
       index_bytes=filelength (handle);
    index_bytes=index_bytes>>1;
    if ((index_file=fopen (index_file_name,"rb"))==NULL)
    {
	printf ("This file no find !!!");
	exit (1);
    }

    close ( handle );
    if ((index_buf=new int [index_bytes])==NULL)
    {
	printf("Memory out !!!");
	exit (2);
    }
    fread (index_buf,4,index_bytes,index_file);
}

void CPicture_imageall::image_close_index (void)
{
    fclose ( index_file );
    delete (index_buf);
}

BOOL CPicture_imageall::LoadBitmap( CDDSurface *pSurface, int index ,int bTrans)
{
	long    compress_width;
    long    compress_height;
	long    compress_imagesize;
    char  * compress_backup;
	long    compress_hand [4];
	//char  * point_backup;
	long   Width;
	/*
	if ((compress_buf=new char [compress_bytes])==NULL)
    {
		printf("Memory out !!!");
		exit (2);
    }
    fread (compress_buf,1,compress_bytes,compress_file);
	*/
	fseek (compress_file,*(index_buf+index),SEEK_SET);
	fread (compress_hand,1,16,compress_file);
	
	//compress_backup=compress_buf+*(index_buf+index);
	//point_backup+=(x+y*screen_width);
    compress_width=compress_hand[0];//*((int *) compress_backup);//-4;
    compress_height=compress_hand[1];//*((int *) compress_backup);//-4;
	compress_imagesize=compress_hand[2];//*((int *) compress_backup);
    if ((compress_width%4)!=0)
    {
		Width=(((compress_width>>2)<<2)+4);//-bmp_hand.biWidth;
	//printf ("\n bmp_hand.biWidth=%d",Width);
    }
    else
		Width=compress_width;
	//compress_height=*((int *) compress_backup);//-4;
    //compress_backup+=12;
	//if ((compress_buf=new char [compress_imagesize])==NULL)
	if ((compress_buf=new char [Width*compress_height])==NULL)
    {
		printf("Memory out !!!");
		exit (2);
    }
	fseek (compress_file,*(index_buf+index)+16,SEEK_SET);
    fread (compress_buf,1,compress_imagesize,compress_file);
/*
	compress_backup=compress_buf;
	for( int i=0; i<compress_imagesize; i++ )
	{
		if( *compress_backup == 0xFF )
			*compress_backup == 0xFE;
		compress_backup++;
	}
*/
	compress_backup=compress_buf;
	if( !pSurface->Create( compress_width, compress_height, bTrans, FALSE ) )
		return FALSE; //分配内存;//lwc
	LPDIRECTDRAWSURFACE2 pSurDest = pSurface->GetSurface();
	DDSURFACEDESC       ddsd;
	ddsd.dwSize = sizeof( ddsd );
	if( pSurDest->Lock( NULL, &ddsd, DDLOCK_WAIT, NULL ) == DD_OK )
	{
		//memset( ddsd.lpSurface, 88, 3000 );
		BYTE *pb = (BYTE *)ddsd.lpSurface;
		//for (int i=0; i<100; i++)
		for( int i=0; i< compress_height; i++ )
		{
			//memset ( pb, 88,3000);
			memcpy ( pb, (BYTE *)compress_backup, compress_width );
			//pb += Width;   //宽度;ture
			pb += ddsd.lPitch;   //宽度;ture
			compress_backup+=Width;
			//pb+=300;
		}
		pSurDest->Unlock( NULL );
	}

	// ddsd.dwWidth
	// ddsd.dwHeight
    delete (compress_buf);

	return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -