base init

This commit is contained in:
d1str4ught
2025-08-18 00:36:52 +02:00
parent cff3015742
commit 4e679320a3
527 changed files with 199969 additions and 0 deletions

53
src/libgame/targa.cpp Normal file
View File

@@ -0,0 +1,53 @@
#include "../../libthecore/include/stdafx.h"
#include <stdio.h>
#include <string.h>
#include "targa.h"
CTargaImage::CTargaImage()
: m_pbuf(NULL), m_x(0), m_y(0)
{
memset( &m_header, 0, sizeof(m_header) );
}
CTargaImage::~CTargaImage()
{
if (m_pbuf)
delete [] m_pbuf;
}
char * CTargaImage::GetBasePointer(int line)
{
return m_pbuf + (m_x * line) * sizeof(DWORD);
}
void CTargaImage::Create(int x, int y)
{
memset(&m_header, 0, sizeof(m_header));
m_header.imgType = 2;
m_header.width = x;
m_header.height = y;
m_header.colorBits = 32;
m_header.desc = 0x20;
m_pbuf = new char[x * y * sizeof(DWORD)];
memset(m_pbuf, 0, x * y * sizeof(DWORD));
m_x = x;
m_y = y;
}
bool CTargaImage::Save(const char * filename)
{
FILE * fp = fopen(filename, "wb");
if (!fp)
return false;
fwrite(&m_header, sizeof(TGA_HEADER), 1, fp);
fwrite(m_pbuf, m_x * m_y * sizeof(DWORD), 1, fp);
fclose(fp);
return true;
}