mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00
Add still-frame PNG image device for use by digitizers/cameras/etc. [R. Belmont]
Other formats can be added, we already have libjpeg in 3rdparty/.
This commit is contained in:
parent
ccfc99ef59
commit
f6e204b4ae
@ -57,6 +57,8 @@ files {
|
|||||||
MAME_DIR .. "src/devices/imagedev/midiin.h",
|
MAME_DIR .. "src/devices/imagedev/midiin.h",
|
||||||
MAME_DIR .. "src/devices/imagedev/midiout.cpp",
|
MAME_DIR .. "src/devices/imagedev/midiout.cpp",
|
||||||
MAME_DIR .. "src/devices/imagedev/midiout.h",
|
MAME_DIR .. "src/devices/imagedev/midiout.h",
|
||||||
|
MAME_DIR .. "src/devices/imagedev/picture.cpp",
|
||||||
|
MAME_DIR .. "src/devices/imagedev/picture.h",
|
||||||
MAME_DIR .. "src/devices/imagedev/printer.cpp",
|
MAME_DIR .. "src/devices/imagedev/printer.cpp",
|
||||||
MAME_DIR .. "src/devices/imagedev/printer.h",
|
MAME_DIR .. "src/devices/imagedev/printer.h",
|
||||||
MAME_DIR .. "src/devices/imagedev/snapquik.cpp",
|
MAME_DIR .. "src/devices/imagedev/snapquik.cpp",
|
||||||
|
64
src/devices/imagedev/picture.cpp
Normal file
64
src/devices/imagedev/picture.cpp
Normal file
@ -0,0 +1,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")
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// microdrive_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),
|
||||||
|
m_picture(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// microdrive_image_device - destructor
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
picture_image_device::~picture_image_device()
|
||||||
|
{
|
||||||
|
if (m_picture)
|
||||||
|
{
|
||||||
|
delete m_picture;
|
||||||
|
m_picture = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void picture_image_device::device_start()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
image_init_result picture_image_device::call_load()
|
||||||
|
{
|
||||||
|
m_picture = new bitmap_argb32;
|
||||||
|
if (png_read_bitmap(image_core_file(), *m_picture) != PNGERR_NONE)
|
||||||
|
{
|
||||||
|
return image_init_result::FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return image_init_result::PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void picture_image_device::call_unload()
|
||||||
|
{
|
||||||
|
}
|
58
src/devices/imagedev/picture.h
Normal file
58
src/devices/imagedev/picture.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// license:BSD-3-Clause
|
||||||
|
// copyright-holders:R. Belmont
|
||||||
|
/*********************************************************************
|
||||||
|
|
||||||
|
picture.h
|
||||||
|
|
||||||
|
Image device that loads still pictures (currently PNG)
|
||||||
|
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
#ifndef MAME_DEVICES_IMAGEDEV_PICTURE_H
|
||||||
|
#define MAME_DEVICES_IMAGEDEV_PICTURE_H
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "bitmap.h"
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
TYPE DEFINITIONS
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
// ======================> microdrive_image_device
|
||||||
|
|
||||||
|
class picture_image_device : public device_t,
|
||||||
|
public device_image_interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// construction/destruction
|
||||||
|
picture_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
|
||||||
|
virtual ~picture_image_device();
|
||||||
|
|
||||||
|
// image-level overrides
|
||||||
|
virtual image_init_result call_load() override;
|
||||||
|
virtual void call_unload() override;
|
||||||
|
virtual iodevice_t image_type() const override { return IO_PICTURE; }
|
||||||
|
|
||||||
|
virtual bool is_readable() const override { return 1; }
|
||||||
|
virtual bool is_writeable() const override { return 0; }
|
||||||
|
virtual bool is_creatable() const override { return 0; }
|
||||||
|
virtual bool must_be_loaded() const override { return 0; }
|
||||||
|
virtual bool is_reset_on_load() const override { return 0; }
|
||||||
|
virtual const char *file_extensions() const override { return "png"; }
|
||||||
|
|
||||||
|
bitmap_argb32 &get_bitmap() { return *m_picture; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// device-level overrides
|
||||||
|
virtual void device_start() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bitmap_argb32 *m_picture;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// device type definition
|
||||||
|
DECLARE_DEVICE_TYPE(IMAGE_PICTURE, picture_image_device)
|
||||||
|
|
||||||
|
#endif // MAME_DEVICES_IMAGEDEV_PICTURE_H
|
@ -45,7 +45,8 @@ const image_device_type_info device_image_interface::m_device_info_array[] =
|
|||||||
{ IO_MAGTAPE, "magtape", "magt" }, /* 14 */
|
{ IO_MAGTAPE, "magtape", "magt" }, /* 14 */
|
||||||
{ IO_ROM, "romimage", "rom" }, /* 15 */
|
{ IO_ROM, "romimage", "rom" }, /* 15 */
|
||||||
{ IO_MIDIIN, "midiin", "min" }, /* 16 */
|
{ IO_MIDIIN, "midiin", "min" }, /* 16 */
|
||||||
{ IO_MIDIOUT, "midiout", "mout" } /* 17 */
|
{ IO_MIDIOUT, "midiout", "mout" }, /* 17 */
|
||||||
|
{ IO_PICTURE, "picture", "pic" } /* 18 */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +50,8 @@ enum iodevice_t
|
|||||||
IO_ROM, /* 16 - Individual ROM image - the Amstrad CPC has a few applications that were sold on 16kB ROMs */
|
IO_ROM, /* 16 - Individual ROM image - the Amstrad CPC has a few applications that were sold on 16kB ROMs */
|
||||||
IO_MIDIIN, /* 17 - MIDI In port */
|
IO_MIDIIN, /* 17 - MIDI In port */
|
||||||
IO_MIDIOUT, /* 18 - MIDI Out port */
|
IO_MIDIOUT, /* 18 - MIDI Out port */
|
||||||
IO_COUNT /* 19 - Total Number of IO_devices for searching */
|
IO_PICTURE, /* 19 - A single-frame image */
|
||||||
|
IO_COUNT /* 20 - Total Number of IO_devices for searching */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum image_error_t
|
enum image_error_t
|
||||||
|
Loading…
Reference in New Issue
Block a user