Commit f1ef8d2f authored by hybrid's avatar hybrid

Reindentation and small updates.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@793 dfc29bdd-3216-0410-991c-e03cc46cb475
parent e29ebb3c
......@@ -320,6 +320,23 @@ bool CD3D9Texture::createTexture(u32 flags)
}
D3DFORMAT CD3D9Texture::getD3DFormatFromColorFormat(ECOLOR_FORMAT format) const
{
switch(format)
{
case ECF_A1R5G5B5:
return D3DFMT_A1R5G5B5;
case ECF_R5G6B5:
return D3DFMT_R5G6B5;
case ECF_R8G8B8:
return D3DFMT_R8G8B8;
case ECF_A8R8G8B8:
return D3DFMT_A8R8G8B8;
}
return D3DFMT_UNKNOWN;
}
ECOLOR_FORMAT CD3D9Texture::getColorFormatFromD3DFormat(D3DFORMAT format)
{
switch(format)
......@@ -419,7 +436,6 @@ bool CD3D9Texture::copyTo16BitTexture()
}
//! destructor
CD3D9Texture::~CD3D9Texture()
{
......
......@@ -85,20 +85,26 @@ private:
//! copies the image to the texture
bool copyTexture();
//! convert color formats
ECOLOR_FORMAT getColorFormatFromD3DFormat(D3DFORMAT format);
//! optimized for 16 bit to 16 copy.
bool copyTo16BitTexture();
//! copies texture to 32 bit hardware texture
bool copyTo32BitTexture();
//! Get D3D color format from Irrlicht color format.
D3DFORMAT getD3DFormatFromColorFormat(ECOLOR_FORMAT format) const;
//! Get Irrlicht color format from D3D color format.
ECOLOR_FORMAT getColorFormatFromD3DFormat(D3DFORMAT format);
//! Helper function for mipmap generation.
bool createMipMaps(u32 level=1);
//! Helper function for mipmap generation.
void copy16BitMipMap(char* src, char* tgt,
s32 width, s32 height, s32 pitchsrc, s32 pitchtgt);
//! Helper function for mipmap generation.
void copy32BitMipMap(char* src, char* tgt,
s32 width, s32 height, s32 pitchsrc, s32 pitchtgt);
......
This diff is collapsed.
......@@ -944,7 +944,7 @@ CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<s32>& size, void* d
{
Data = 0;
initData();
memcpy(Data, data, Size.Height * Size.Width * BytesPerPixel);
memcpy(Data, data, Size.Height * Pitch);
}
}
......@@ -1281,25 +1281,44 @@ void CImage::copyToScaling(void* target, s32 width, s32 height, ECOLOR_FORMAT fo
if (0==pitch)
pitch = width*bpp;
if (Format==format && Size.Width==width && Size.Height==height && pitch==width*bpp)
if (Format==format && Size.Width==width && Size.Height==height)
{
memcpy(target, Data, height*pitch);
return;
if (pitch==Pitch)
{
memcpy(target, Data, height*pitch);
return;
}
else
{
u8* tgtpos = (u8*) target;
u8* dstpos = (u8*) Data;
const u32 bwidth = width*bpp;
for (s32 y=0; y<height; ++y)
{
memcpy(target, Data, height*pitch);
memset(tgtpos+width, 0, pitch-bwidth);
tgtpos += pitch;
dstpos += Pitch;
}
return;
}
}
const f32 sourceXStep = (f32)Size.Width / (f32)width;
const f32 sourceYStep = (f32)Size.Height / (f32)height;
f32 sx,sy;
sy = 0.0f;
s32 yval=0, syval=0;
f32 sy = 0.0f;
for (s32 y=0; y<height; ++y)
{
sx = 0.0f;
f32 sx = 0.0f;
for (s32 x=0; x<width; ++x)
{
CColorConverter::convert_viaFormat(((u8*)Data)+(((s32)sy)*Size.Width + (s32)sx)*BytesPerPixel, Format, 1, ((u8*)target)+(y*pitch + x*bpp), format);
CColorConverter::convert_viaFormat(((u8*)Data)+ syval + ((s32)sx)*BytesPerPixel, Format, 1, ((u8*)target)+ yval + (x*bpp), format);
sx+=sourceXStep;
}
sy+=sourceYStep;
syval=((s32)sy)*Pitch;
yval+=pitch;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment