#include "CImage.h"

#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>

#define BITMAP_ID            0x4D42 // universal id for a bitmap
#include "Assert.h"

void CImage::getWidthHeight(STRINGC file)
{
	if(1==1)
		return;

	int file_handle, index=0;	
	OFSTRUCT file_data;				//file data information
	//open the file, return error if it doesnt exist

	if((file_handle = OpenFile((char *)file, &file_data, OF_READ))== -1)
	{
		Assert( false, "Couldn't open .bmp file")
		return;
	}

	
	//This reads in the BitmapFileHeader
	_lread(file_handle, &bitmapfileheader, sizeof(BITMAPFILEHEADER));

	if(bitmapfileheader.bfType != BITMAP_ID)
	{
		_lclose(file_handle);	//close file
		Assert( false, "Tried to open a file as bmp, that wasnt a bmp")
		return ;
	}

	_lread(file_handle, &bitmapinfoheader, sizeof(BITMAPINFOHEADER));
	_lseek(file_handle, -(int)(bitmapinfoheader.biSizeImage), SEEK_END);		//butmapinfoheader.bifSizeImage?
	_lclose(file_handle);
	
	this->setWidth(bitmapinfoheader.biWidth);
	this->setHeight(bitmapinfoheader.biHeight);

	setCenter(getWidth()/2, getHeight()/2);

	return;

}

//----------------------------------------------------------------//
//
//----------------------------------------------------------------//





  