亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? demo7_10.cpp

?? windows游戲編程大師源代碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
// DEMO7_10.CPP 8-bit bitmap loading demo

// INCLUDES ///////////////////////////////////////////////

#define WIN32_LEAN_AND_MEAN  // just say no to MFC

#define INITGUID

#include <windows.h>   // include important windows stuff
#include <windowsx.h> 
#include <mmsystem.h>
#include <iostream.h> // include important C/C++ stuff
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h> 
#include <math.h>
#include <io.h>
#include <fcntl.h>

#include <ddraw.h> // include directdraw

// DEFINES ////////////////////////////////////////////////

// defines for windows 
#define WINDOW_CLASS_NAME "WINCLASS1"

// default screen size
#define SCREEN_WIDTH    640  // size of screen
#define SCREEN_HEIGHT   480
#define SCREEN_BPP      8    // bits per pixel

#define BITMAP_ID            0x4D42 // universal id for a bitmap
#define MAX_COLORS_PALETTE   256

// TYPES //////////////////////////////////////////////////////

// basic unsigned types
typedef unsigned short USHORT;
typedef unsigned short WORD;
typedef unsigned char  UCHAR;
typedef unsigned char  BYTE;

// container structure for bitmaps .BMP file
typedef struct BITMAP_FILE_TAG
        {
        BITMAPFILEHEADER bitmapfileheader;  // this contains the bitmapfile header
        BITMAPINFOHEADER bitmapinfoheader;  // this is all the info including the palette
        PALETTEENTRY     palette[256];      // we will store the palette here
        UCHAR            *buffer;           // this is a pointer to the data

        } BITMAP_FILE, *BITMAP_FILE_PTR;

// PROTOTYPES  //////////////////////////////////////////////

int Flip_Bitmap(UCHAR *image, int bytes_per_line, int height);

int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename);

int Unload_Bitmap_File(BITMAP_FILE_PTR bitmap);

int DDraw_Fill_Surface(LPDIRECTDRAWSURFACE4 lpdds,int color);

// MACROS /////////////////////////////////////////////////

// tests if a key is up or down
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEYUP(vk_code)   ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)

// initializes a direct draw struct
#define DDRAW_INIT_STRUCT(ddstruct) { memset(&ddstruct,0,sizeof(ddstruct)); ddstruct.dwSize=sizeof(ddstruct); }

// GLOBALS ////////////////////////////////////////////////

HWND      main_window_handle = NULL; // globally track main window
int       window_closed      = 0;    // tracks if window is closed
HINSTANCE hinstance_app      = NULL; // globally track hinstance

// directdraw stuff

LPDIRECTDRAW          lpdd         = NULL;   // dd object
LPDIRECTDRAW4         lpdd4        = NULL;   // dd4 object
LPDIRECTDRAWSURFACE4  lpddsprimary = NULL;   // dd primary surface
LPDIRECTDRAWSURFACE4  lpddsback    = NULL;   // dd back surface
LPDIRECTDRAWPALETTE   lpddpal      = NULL;   // a pointer to the created dd palette
LPDIRECTDRAWCLIPPER   lpddclipper  = NULL;   // dd clipper
PALETTEENTRY          palette[256];          // color palette
PALETTEENTRY          save_palette[256];     // used to save palettes
DDSURFACEDESC2        ddsd;                  // a direct draw surface description struct
DDBLTFX               ddbltfx;               // used to fill
DDSCAPS2              ddscaps;               // a direct draw surface capabilities struct
HRESULT               ddrval;                // result back from dd calls
DWORD                 start_clock_count = 0; // used for timing

BITMAP_FILE           bitmap;                // holds the bitmap

char buffer[80];                             // general printing buffer

// FUNCTIONS ////////////////////////////////////////////////

int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename)
{
// this function opens a bitmap file and loads the data into bitmap

int file_handle,  // the file handle
    index;        // looping index

UCHAR   *temp_buffer = NULL; // used to convert 24 bit images to 16 bit
OFSTRUCT file_data;          // the file data information

// open the file if it exists
if ((file_handle = OpenFile(filename,&file_data,OF_READ))==-1)
   return(0);

// now load the bitmap file header
_lread(file_handle, &bitmap->bitmapfileheader,sizeof(BITMAPFILEHEADER));

// test if this is a bitmap file
if (bitmap->bitmapfileheader.bfType!=BITMAP_ID)
   {
   // close the file
   _lclose(file_handle);

   // return error
   return(0);
   } // end if

// now we know this is a bitmap, so read in all the sections

// first the bitmap infoheader

// now load the bitmap file header
_lread(file_handle, &bitmap->bitmapinfoheader,sizeof(BITMAPINFOHEADER));

// now load the color palette if there is one
if (bitmap->bitmapinfoheader.biBitCount == 8)
   {
   _lread(file_handle, &bitmap->palette,MAX_COLORS_PALETTE*sizeof(PALETTEENTRY));

   // now set all the flags in the palette correctly and fix the reversed 
   // BGR RGBQUAD data format
   for (index=0; index < MAX_COLORS_PALETTE; index++)
       {
       // reverse the red and green fields
       int temp_color                = bitmap->palette[index].peRed;
       bitmap->palette[index].peRed  = bitmap->palette[index].peBlue;
       bitmap->palette[index].peBlue = temp_color;
       
       // always set the flags word to this
       bitmap->palette[index].peFlags = PC_NOCOLLAPSE;
       } // end for index

    } // end if

// finally the image data itself
_lseek(file_handle,-(int)(bitmap->bitmapinfoheader.biSizeImage),SEEK_END);

// now read in the image, if the image is 8 or 16 bit then simply read it
// but if its 24 bit then read it into a temporary area and then convert
// it to a 16 bit image

if (bitmap->bitmapinfoheader.biBitCount==8 || bitmap->bitmapinfoheader.biBitCount==16 || 
    bitmap->bitmapinfoheader.biBitCount==24)
   {
   // delete the last image if there was one
   if (bitmap->buffer)
       free(bitmap->buffer);

   // allocate the memory for the image
   if (!(bitmap->buffer = (UCHAR *)malloc(bitmap->bitmapinfoheader.biSizeImage)))
      {
      // close the file
      _lclose(file_handle);

      // return error
      return(0);
      } // end if

   // now read it in
   _lread(file_handle,bitmap->buffer,bitmap->bitmapinfoheader.biSizeImage);

   } // end if
else
   {
   // serious problem
   return(0);

   } // end else

#if 0
// write the file info out 
printf("\nfilename:%s \nsize=%d \nwidth=%d \nheight=%d \nbitsperpixel=%d \ncolors=%d \nimpcolors=%d",
        filename,
        bitmap->bitmapinfoheader.biSizeImage,
        bitmap->bitmapinfoheader.biWidth,
        bitmap->bitmapinfoheader.biHeight,
		bitmap->bitmapinfoheader.biBitCount,
        bitmap->bitmapinfoheader.biClrUsed,
        bitmap->bitmapinfoheader.biClrImportant);
#endif

// close the file
_lclose(file_handle);

// flip the bitmap
Flip_Bitmap(bitmap->buffer, 
            bitmap->bitmapinfoheader.biWidth*(bitmap->bitmapinfoheader.biBitCount/8), 
            bitmap->bitmapinfoheader.biHeight);

// return success
return(1);

} // end Load_Bitmap_File

///////////////////////////////////////////////////////////

int Unload_Bitmap_File(BITMAP_FILE_PTR bitmap)
{
// this function releases all memory associated with "bitmap"
if (bitmap->buffer)
   {
   // release memory
   free(bitmap->buffer);

   // reset pointer
   bitmap->buffer = NULL;

   } // end if

// return success
return(1);

} // end Unload_Bitmap_File

///////////////////////////////////////////////////////////

int Flip_Bitmap(UCHAR *image, int bytes_per_line, int height)
{
// this function is used to flip bottom-up .BMP images

UCHAR *buffer; // used to perform the image processing
int index;     // looping index

// allocate the temporary buffer
if (!(buffer = (UCHAR *)malloc(bytes_per_line*height)))
   return(0);

// copy image to work area
memcpy(buffer,image,bytes_per_line*height);

// flip vertically
for (index=0; index < height; index++)
    memcpy(&image[((height-1) - index)*bytes_per_line],
           &buffer[index*bytes_per_line], bytes_per_line);

// release the memory
free(buffer);

// return success
return(1);

} // end Flip_Bitmap

///////////////////////////////////////////////////////////////

int DDraw_Fill_Surface(LPDIRECTDRAWSURFACE4 lpdds,int color)
{
DDBLTFX ddbltfx; // this contains the DDBLTFX structure

// clear out the structure and set the size field 
DDRAW_INIT_STRUCT(ddbltfx);

// set the dwfillcolor field to the desired color
ddbltfx.dwFillColor = color; 

// ready to blt to surface
lpdds->Blt(NULL,       // ptr to dest rectangle
           NULL,       // ptr to source surface, NA            
           NULL,       // ptr to source rectangle, NA
           DDBLT_COLORFILL | DDBLT_WAIT,   // fill and wait                   
           &ddbltfx);  // ptr to DDBLTFX structure

// return success
return(1);
} // end DDraw_Fill_Surface


///////////////////////////////////////////////////////////////

LRESULT CALLBACK WindowProc(HWND hwnd, 
						    UINT msg, 
                            WPARAM wparam, 
                            LPARAM lparam)
{
// this is the main message handler of the system
PAINTSTRUCT		ps;		// used in WM_PAINT
HDC				hdc;	// handle to a device context
char buffer[80];        // used to print strings

// what is the message 
switch(msg)
	{	
	case WM_CREATE: 
        {
		// do initialization stuff here
        // return success
		return(0);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩免费看网站| 99久久99久久免费精品蜜臀| 欧美精品第一页| 性欧美大战久久久久久久久| 欧美日韩免费一区二区三区 | 国产91在线看| 欧美国产欧美综合| 色中色一区二区| 亚洲不卡在线观看| 精品少妇一区二区三区日产乱码| 国产在线乱码一区二区三区| 国产精品国产三级国产三级人妇| 99在线视频精品| 午夜精品久久久久久久| 日韩视频在线永久播放| 成人av资源下载| 亚洲午夜一区二区| 精品国产乱码久久久久久浪潮| 成人综合在线视频| 图片区小说区区亚洲影院| 欧美本精品男人aⅴ天堂| 成人a级免费电影| 天天操天天综合网| 中文文精品字幕一区二区| 欧美在线免费播放| 国产经典欧美精品| 亚洲一二三区在线观看| 久久蜜桃av一区二区天堂| 91丨porny丨在线| 美女精品自拍一二三四| 综合色中文字幕| 日韩视频在线永久播放| 色天使久久综合网天天| 精品一区二区三区在线播放视频| 亚洲欧美乱综合| 久久久久久久久久久久久久久99| 91福利小视频| 成人免费视频播放| 美女网站在线免费欧美精品| 成人欧美一区二区三区小说| 精品国产免费人成电影在线观看四季 | 免费在线观看成人| 亚洲精品成a人| 欧美国产综合色视频| 91精品国产综合久久久蜜臀粉嫩 | 国产成人啪免费观看软件| 亚洲成人av中文| 国产精品久久久久久久久果冻传媒 | 亚洲欧美日韩国产成人精品影院 | 26uuu精品一区二区在线观看| 色综合天天性综合| 久久久久综合网| 中文字幕中文字幕一区二区| 日韩欧美一级在线播放| 欧美偷拍一区二区| 91原创在线视频| 大尺度一区二区| 国产精品资源在线看| 日本成人中文字幕| 亚洲永久精品大片| 亚洲精品国产品国语在线app| 337p日本欧洲亚洲大胆色噜噜| 欧美日韩在线亚洲一区蜜芽| av激情综合网| eeuss鲁一区二区三区| 国产99久久久精品| 国产综合久久久久久鬼色| 日本亚洲天堂网| 午夜电影一区二区| 午夜私人影院久久久久| 亚洲影院免费观看| 亚洲一区二区欧美| 一区二区国产视频| 亚洲乱码中文字幕| 亚洲黄色尤物视频| 亚洲午夜av在线| 亚洲综合在线观看视频| 亚洲另类在线一区| 日韩一区在线免费观看| 亚洲男人的天堂av| 一个色综合av| 亚洲a一区二区| 日韩电影在线免费看| 视频一区在线播放| 麻豆视频观看网址久久| 精品综合久久久久久8888| 日本不卡视频在线观看| 久久99久久99| 国产盗摄精品一区二区三区在线 | 色吧成人激情小说| 欧美日本免费一区二区三区| 7777精品伊人久久久大香线蕉的| 在线不卡的av| 欧美一二三区在线观看| 久久综合久久久久88| 日本一区二区三区电影| 国产精品久久久爽爽爽麻豆色哟哟| 欧美激情一区二区三区不卡| 亚洲私人影院在线观看| 亚洲bt欧美bt精品777| 国内精品免费**视频| aaa欧美色吧激情视频| 欧美老年两性高潮| 精品国产乱码久久久久久久| 中文字幕一区二区三区视频 | 国产亚洲午夜高清国产拍精品| 国产欧美一区二区三区鸳鸯浴| 18成人在线观看| 日韩精品高清不卡| 国产a精品视频| 欧美在线观看你懂的| 26uuu另类欧美亚洲曰本| 亚洲人成影院在线观看| 免费av成人在线| av在线播放成人| 91超碰这里只有精品国产| 国产日韩精品一区二区三区在线| 亚洲免费色视频| 久久66热偷产精品| 972aa.com艺术欧美| 欧美一二三区在线| 日韩一区欧美一区| 国精品**一区二区三区在线蜜桃| 色狠狠一区二区三区香蕉| 欧美一区二区三区在线看| 亚洲国产电影在线观看| 天堂精品中文字幕在线| 99久久精品99国产精品| 日韩欧美黄色影院| 樱花影视一区二区| 国产麻豆精品久久一二三| 欧美人与z0zoxxxx视频| 国产精品情趣视频| 日本不卡高清视频| 欧美写真视频网站| 亚洲欧洲精品天堂一级 | 国产亚洲欧美色| 午夜av一区二区| 91免费版在线| 国产区在线观看成人精品| 污片在线观看一区二区| 在线免费不卡视频| 日本一区二区三区dvd视频在线| 欧美aaa在线| 欧美日韩亚洲不卡| 亚洲在线视频网站| 91麻豆免费视频| 国产精品久久久久久久久免费桃花 | 午夜精品视频在线观看| eeuss鲁片一区二区三区 | 欧美人妇做爰xxxⅹ性高电影| 亚洲视频综合在线| 高清在线观看日韩| 久久一日本道色综合| 视频一区二区三区入口| 欧美性猛交xxxx乱大交退制版| 亚洲天天做日日做天天谢日日欢 | 欧美性色欧美a在线播放| 中文字幕视频一区| 99免费精品在线观看| 久久久久久久精| 韩国中文字幕2020精品| 欧美成人一区二区三区| 日本免费新一区视频| 欧美男男青年gay1069videost| 一区二区三区av电影| 91国偷自产一区二区三区成为亚洲经典| 国产欧美一区二区精品性色超碰| 国产在线不卡一区| www成人在线观看| 国产成人免费视| 日本一区二区免费在线观看视频| 国产精品夜夜嗨| 久久网站热最新地址| 国产高清亚洲一区| 国产精品久久久久久久久晋中 | 91浏览器在线视频| 亚洲日本一区二区三区| 91福利精品视频| 亚洲妇女屁股眼交7| 3d动漫精品啪啪| 日本欧美一区二区| www国产成人| 成人精品免费看| 亚洲激情自拍偷拍| 欧美一卡2卡3卡4卡| 国产成人在线视频网址| 中文字幕制服丝袜成人av| 91激情五月电影| 蜜桃av一区二区在线观看| 久久精品亚洲精品国产欧美| 成人福利在线看| 亚洲成人免费在线| 精品国产免费久久| av色综合久久天堂av综合| 天堂成人免费av电影一区| 久久久久久综合| 在线日韩av片| 九一九一国产精品| 亚洲美腿欧美偷拍|