- Removed DCanvas::Blit(), as it's no longer used.

- Added a function to create a texture from a stand-alone PNG file. The save/
  load menus now use this to get their thumbnails.


SVN r652 (trunk)
This commit is contained in:
Randy Heit 2007-12-28 01:54:14 +00:00
commit 522e7fe07f
10 changed files with 88 additions and 161 deletions

View file

@ -30,9 +30,6 @@
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
** Currently, only 256-color paletted images are supported, as these are all
** that ZDoom needs to support. Expect this to become more complete in the
** future if I decide to add support for graphic patches stored as PNGs.
*/
// HEADER FILES ------------------------------------------------------------
@ -454,66 +451,6 @@ void M_FreePNG (PNGHandle *png)
delete png;
}
//==========================================================================
//
// M_CreateCanvasFromPNG
//
// Creates a simple canvas containing the contents of the PNG file's IDAT
// chunk(s). Only 8-bit images are supported.
//
//==========================================================================
DCanvas *M_CreateCanvasFromPNG (PNGHandle *png)
{
IHDR imageHeader;
DSimpleCanvas *canvas;
int width, height;
unsigned int chunklen;
if (M_FindPNGChunk (png, MAKE_ID('I','H','D','R')) == 0)
{
return NULL;
}
if (png->File->Read (&imageHeader, sizeof(IHDR)) != sizeof(IHDR))
{
return NULL;
}
if (imageHeader.Width == 0 ||
imageHeader.Height == 0 ||
// Only images that M_CreatePNG can write are supported
imageHeader.BitDepth != 8 ||
imageHeader.ColorType != 3 ||
imageHeader.Compression != 0 ||
imageHeader.Filter != 0 ||
imageHeader.Interlace != 0
)
{
return NULL;
}
chunklen = M_FindPNGChunk (png, MAKE_ID('I','D','A','T'));
if (chunklen == 0)
{
return NULL;
}
width = BigLong((int)imageHeader.Width);
height = BigLong((int)imageHeader.Height);
canvas = new DSimpleCanvas (width, height);
if (canvas == NULL)
{
return NULL;
}
canvas->Lock ();
bool success = M_ReadIDAT (png->File, canvas->GetBuffer(), width, height, canvas->GetPitch(), 8, 3, 0, chunklen);
canvas->Unlock ();
if (!success)
{
delete canvas;
canvas = NULL;
}
return canvas;
}
//==========================================================================
//
// ReadIDAT