summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/imagedev/picture.cpp
blob: e50f2c0d4c6bd981d27dda69cc6955ace59466d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// license:BSD-3-Clause
// copyright-holders:R. Belmont
/*********************************************************************

    picture.cpp

    Image device for still pictures.

*********************************************************************/

#include "emu.h"
#include "picture.h"
#include "png.h"

/***************************************************************************
    TYPE DEFINITIONS
***************************************************************************/

// device type definition
DEFINE_DEVICE_TYPE(IMAGE_PICTURE, picture_image_device, "picture_image", "Still Image")

//-------------------------------------------------
//  picture_image_device - constructor
//-------------------------------------------------

picture_image_device::picture_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, IMAGE_PICTURE, tag, owner, clock),
	device_image_interface(mconfig, *this)
{
}

//-------------------------------------------------
//  picture_image_device - destructor
//-------------------------------------------------

picture_image_device::~picture_image_device()
{
}


void picture_image_device::device_start()
{
}

image_init_result picture_image_device::call_load()
{
	if (png_read_bitmap(image_core_file(), m_picture) != PNGERR_NONE)
	{
		m_picture.reset();

		// todo: try JPEG here.
		return image_init_result::FAIL;
	}

	return image_init_result::PASS;
}

void picture_image_device::call_unload()
{
	if (m_picture.valid())
	{
		m_picture.reset();
	}
}