Program stworzony razem ze studentami w ramach zajęc z przedmiotu Zaawansowane Techniki Programowania w Multimediach w semestrze 2017/2018 Mucha
/*//
_ _ _
| | __ _ _ __ ___ | |__ _-(")-
| | / _` | '_ ` _ \| '_ \ `%%%%%
| |__| (_| | | | |_| | |_) | _ // \\
|_____\__,_|_| |_| |_|_.__/_| |__ ___
| | / _` | '_ \/ __|
| |__| (_| | |_) \__ \
2018-05-24 |_____\__,_|_.__/|___/
//*/
#include
#include
//#include
//#include
#include
#include
#include "res.h"
#define IDT_REDRAW_FRAME 2018
GLuint uiTextureEyeID;
GLuint uiTextureBodyID;
unsigned char* ReadBmpFromFile(const char* szFileName, int &riWidth, int &riHeight)
{
BITMAPFILEHEADER bfh;
BITMAPINFOHEADER bih;
int i, j, h, v, lev, l, ls;
unsigned char* buff = NULL;
unsigned char* p_palette = NULL;
unsigned short n_colors = 0;
unsigned char* pRGBBuffer=NULL;
FILE* hfile;
fopen_s(&hfile,szFileName, "rb");
if (hfile != NULL)
{
fread(&bfh, sizeof(bfh), 1, hfile);
if (!(bfh.bfType != 0x4d42 || (bfh.bfOffBits < (sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)))))
{
fread(&bih, sizeof(bih), 1, hfile);
v = bih.biWidth;
h = bih.biHeight;
lev = bih.biBitCount;
riWidth = v;
riHeight = h;
pRGBBuffer = new unsigned char[riWidth*riHeight * 3]; //Zaalokowanie odpowiedniego buffora obrazu
//Załaduj Palete barw jesli jest
if ((lev == 1) || (lev == 4) || (lev == 8))
{
n_colors = 1 << lev;
p_palette = new unsigned char[4 * n_colors];
fread(p_palette, 4 * n_colors, 1, hfile);
}
fseek(hfile, bfh.bfOffBits, SEEK_SET);
buff = new unsigned char[v * 4];
switch (lev)
{
case 1:
//Nie obsługiwane
break;
case 4:
//nie Obsługiwane
break;
case 8: //Skala szarości
ls = (v + 3) & 0xFFFFFFFC;
for (j = (h - 1); j >= 0; j--)
{
fread(buff, ls, 1, hfile);
for (i = 0, l = 0; i= 0; j--)
{
//x_fread(hfile,buff,ls);
fread(buff, ls, 1, hfile);
for (i = 0, l = 0; i= 0; j--)
{
fread(buff, v * 4, 1, hfile);
for (i = 0, l = 0; i