[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r9560: Add PNG-reading capabilities.
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r9560: Add PNG-reading capabilities. This is only for PNG movies; there isn't |
Date: |
Tue, 05 Aug 2008 12:55:08 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9560
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2008-08-05 12:55:08 +0200
message:
Add PNG-reading capabilities. This is only for PNG movies; there isn't
a way of embedding them in a SWF (at least up to version 8).
There still might be something to be said for unifying the interface
to JPEG and PNG.
added:
libbase/GnashImagePng.cpp
libbase/GnashImagePng.h
testsuite/media/png.png
testsuite/misc-ming.all/loadPNGTest.c
modified:
libbase/Makefile.am
libbase/image.cpp
libbase/image.h
libbase/jpeg.cpp
libcore/impl.cpp
testsuite/misc-ming.all/Makefile.am
------------------------------------------------------------
revno: 9554.2.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-05 09:49:05 +0200
message:
Minor cleanups.
modified:
libbase/jpeg.cpp
------------------------------------------------------------
revno: 9554.2.4
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-05 09:50:02 +0200
message:
Add simple PNG reading capabilities.
added:
libbase/GnashPNG.cpp
libbase/GnashPNG.h
modified:
libbase/Makefile.am
------------------------------------------------------------
revno: 9554.2.5
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-05 09:50:38 +0200
message:
Allow reading PNGs. Due to the limitations of BitmapMovieDefinition this
is currently only an RGB image.
modified:
libbase/image.cpp
libbase/image.h
------------------------------------------------------------
revno: 9554.2.6
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-05 09:51:42 +0200
message:
Read PNG movies.
modified:
libcore/impl.cpp
------------------------------------------------------------
revno: 9554.2.7
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-05 10:22:27 +0200
message:
Cleanup on exit, keep track of current scanline (because of the
image class interface).
modified:
libbase/GnashPNG.cpp
libbase/GnashPNG.h
------------------------------------------------------------
revno: 9554.2.8
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-05 11:00:24 +0200
message:
Rename function. Catch ParserException on libpng error and continue.
Add note about version behaviour.
modified:
libcore/impl.cpp
------------------------------------------------------------
revno: 9554.2.9
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-05 11:01:19 +0200
message:
Drop code taken from jpeg.cpp but unused. Make error reporting better.
modified:
libbase/GnashPNG.cpp
libbase/GnashPNG.h
------------------------------------------------------------
revno: 9554.2.10
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-05 12:14:06 +0200
message:
Add sample PNG file (I drew it myself!), and a ming test for loading PNGS
(no test runner yet).
added:
testsuite/media/png.png
testsuite/misc-ming.all/loadPNGTest.c
modified:
testsuite/misc-ming.all/Makefile.am
------------------------------------------------------------
revno: 9554.2.11
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-05 12:15:18 +0200
message:
Improve debugging.
modified:
libcore/impl.cpp
------------------------------------------------------------
revno: 9554.2.12
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-05 12:16:20 +0200
message:
Nothing much changed.
modified:
libbase/jpeg.cpp
------------------------------------------------------------
revno: 9554.2.13
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-05 12:26:33 +0200
message:
Rename PNG files, add copyright info.
renamed:
libbase/GnashPNG.cpp => libbase/GnashImagePng.cpp
libbase/GnashPNG.h => libbase/GnashImagePng.h
modified:
libbase/Makefile.am
libbase/image.cpp
libbase/GnashImagePng.cpp
libbase/GnashImagePng.h
=== added file 'libbase/GnashImagePng.cpp'
--- a/libbase/GnashImagePng.cpp 1970-01-01 00:00:00 +0000
+++ b/libbase/GnashImagePng.cpp 2008-08-05 10:26:33 +0000
@@ -0,0 +1,178 @@
+// png.cpp: libpng wrapper for Gnash.
+//
+// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+extern "C" {
+#include <png.h>
+}
+
+#include "utility.h"
+#include "GnashImagePng.h"
+#include "tu_file.h"
+#include "log.h"
+#include "GnashException.h"
+
+#include <sstream>
+
+namespace gnash {
+namespace png {
+
+/// input/output wrappers for IOChannel
+namespace IOChannel_wrappers
+{
+
+ class pngIOChannel : public input
+ {
+ private:
+ // State needed for input.
+ png_structp _pngPtr;
+ png_infop _infoPtr;
+
+ // A reference to the stream containing the PNG data.
+ IOChannel& _inStream;
+
+ // A counter for keeping track of the last row copied.
+ size_t _currentRow;
+
+ public:
+
+ /// Constructor.
+ //
+ /// @param in
+ /// The stream to read from.
+ pngIOChannel(gnash::IOChannel& in) :
+ _pngPtr(0),
+ _infoPtr(0),
+ _inStream(in),
+ _currentRow(0)
+ {
+ init();
+ }
+
+ static void error(png_struct*, const char* msg)
+ {
+ std::ostringstream ss;
+ ss << "PNG error: " << msg;
+ throw ParserException(ss.str());
+ }
+
+ static void warning(png_struct*, const char* msg)
+ {
+ log_debug(_("PNG warning: %s"), msg);
+ }
+
+ // Read function using a gnash::IOChannel
+ static void readData(png_structp pngptr,
+ png_bytep data, png_size_t length)
+ {
+ // Do not call unless the PNG exists.
+ assert (pngptr);
+ IOChannel* in =
reinterpret_cast<IOChannel*>(png_get_io_ptr(pngptr));
+ in->read(reinterpret_cast<char*>(data), length);
+ }
+
+ void init()
+ {
+ // Initialize png library.
+ _pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
+ NULL, &error, &warning);
+ if (!_pngPtr) return;
+
+ _infoPtr = png_create_info_struct(_pngPtr);
+
+ if (!_infoPtr)
+ {
+ png_destroy_read_struct(&_pngPtr, (png_infopp)NULL,
(png_infopp)NULL);
+ return;
+ }
+ }
+
+ void read()
+ {
+ // Set our user-defined reader function
+ png_set_read_fn(_pngPtr, &_inStream, &readData);
+
+ // read
+ // TODO: sort out transform options.
+ png_read_png(_pngPtr, _infoPtr, PNG_TRANSFORM_STRIP_ALPHA, NULL);
+ }
+
+ // Destructor. Free libpng-allocated memory.
+ ~pngIOChannel()
+ {
+ png_destroy_read_struct(&_pngPtr, &_infoPtr, (png_infopp)NULL);
+ }
+
+ // Return the height of the image.
+ size_t getHeight() const
+ {
+ assert (_pngPtr && _infoPtr);
+ return png_get_image_height(_pngPtr, _infoPtr);
+ }
+
+ // Return the width of the image.
+ size_t getWidth() const
+ {
+ assert (_pngPtr && _infoPtr);
+ return png_get_image_width(_pngPtr, _infoPtr);
+ }
+
+ // Return number of components (i.e. == 3 for RGB
+ // data). The size of the data for a scanline is
+ // get_width() * get_components().
+ //
+ int getComponents() const
+ {
+ return 3;
+ }
+
+ // Read a scanline's worth of image data into the
+ // given buffer. The amount of data read is
+ // get_width() * get_components().
+ //
+ void readScanline(unsigned char* rgb_data)
+ {
+ assert (_currentRow < getHeight());
+ png_bytepp row_pointers = png_get_rows(_pngPtr, _infoPtr);
+ std::memcpy(rgb_data, row_pointers[_currentRow], getWidth()
* getComponents());
+ ++_currentRow;
+ }
+ };
+
+} // namespace IOChannel_wrappers
+
+
+std::auto_ptr<input>
+input::create(gnash::IOChannel& in)
+{
+ using IOChannel_wrappers::pngIOChannel;
+ std::auto_ptr<input> ret ( new pngIOChannel(in) );
+ if ( ret.get() ) ret->read(); // might throw an exception (I guess)
+ return ret;
+}
+
+
+} // namespace png
+} // namespace gnash
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 8
+// tab-width: 8
+// indent-tabs-mode: t
+// End:
=== added file 'libbase/GnashImagePng.h'
--- a/libbase/GnashImagePng.h 1970-01-01 00:00:00 +0000
+++ b/libbase/GnashImagePng.h 2008-08-05 10:26:33 +0000
@@ -0,0 +1,103 @@
+// png.h: libpng wrapper for Gnash.
+//
+// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifndef GNASH_IMAGE_PNG_H
+#define GNASH_IMAGE_PNG_H
+
+#include "dsodefs.h"
+#include <csetjmp> // for jmp_buf
+#include <memory>
+
+// Forward declarations
+namespace gnash { class IOChannel; }
+
+namespace gnash {
+namespace png {
+
+ class input {
+
+ public:
+
+ input()
+ {}
+
+ virtual ~input() {}
+
+
+ /// \brief
+ /// Create and return a jpeg-input object that will read from
the
+ /// given input stream.
+ //
+ /// The created input reads the jpeg header
+ ///
+ /// @param in
+ /// The stream to read from. Ownership specified by last
arg.
+ ///
+ /// @param takeOwnership
+ /// If false, ownership of the stream
+ /// is left to caller, otherwise we take it.
+ /// NOTE: In case the caller retains ownership, it must
+ /// make sure the stream is alive and not modified
+ /// for the whole lifetime of the returned instance.
+ ///
+ /// @return NULL on error
+ ///
+ DSOEXPORT static std::auto_ptr<input> create(gnash::IOChannel&
in);
+
+ /// Read SWF JPEG2-style header.
+ //
+ /// App needs to call start_image() before loading any
+ /// image data. Multiple images can be loaded by
+ /// bracketing within start_image()/finish_image() pairs.
+ ///
+ /// @param in
+ /// The gnash::IOChannel to use for input. Ownership
specified
+ /// by last arg.
+ ///
+ /// @param maxHeaderBytes
+ /// Max number of bytes to read from input for header.
+ ///
+ /// @param takeOwnership
+ /// If false, ownership of the stream
+ /// is left to caller, otherwise we take it.
+ /// NOTE: In case the caller retains ownership, it must
+ /// make sure the stream is alive and not modified
+ /// for the whole lifetime of the returned instance.
+ ///
+ /// @return NULL on error
+ ///
+// DSOEXPORT std::auto_ptr<input>
create_swf_jpeg2_header_only(gnash::IOChannel* in,
+// unsigned int maxHeaderBytes, bool
takeOwnership=false);
+
+ /// Discard existing bytes in our buffer.
+
+ virtual void read() = 0;
+
+ virtual size_t getHeight() const = 0;
+ virtual size_t getWidth() const = 0;
+ virtual void readScanline(unsigned char* rgb_data) = 0;
+
+ };
+
+} // namespace png
+} // namespace gnash
+
+
+
+#endif
=== modified file 'libbase/Makefile.am'
--- a/libbase/Makefile.am 2008-07-29 22:26:53 +0000
+++ b/libbase/Makefile.am 2008-08-05 10:26:33 +0000
@@ -68,6 +68,7 @@
libgnashbase_la_LIBADD = \
$(JPEG_LIBS) \
+ $(PNG_LIBS) \
$(Z_LIBS) \
$(CURL_LIBS) \
$(OPENGL_LIBS) \
@@ -92,6 +93,7 @@
image.cpp \
$(MALLOC) \
jpeg.cpp \
+ GnashImagePng.cpp \
log.cpp \
memory.cpp \
rc.cpp \
@@ -122,6 +124,7 @@
image.h \
jemtree.h \
jpeg.h \
+ GnashImagePng.h \
gmemory.h \
log.h \
ogl.h \
=== modified file 'libbase/image.cpp'
--- a/libbase/image.cpp 2008-07-16 14:15:30 +0000
+++ b/libbase/image.cpp 2008-08-05 10:26:33 +0000
@@ -9,6 +9,7 @@
#include "utility.h"
#include "jpeg.h"
+#include "GnashImagePng.h"
#include "IOChannel.h"
#include "tu_file.h" // some functions take a filename, tu_file is created in
that case..
@@ -214,7 +215,6 @@
}
}
-
// Create and read a new image from the stream.
//
// TODO: return by auto_ptr !
@@ -234,6 +234,22 @@
return im.release();
}
+ std::auto_ptr<rgb> readSWFPng(gnash::IOChannel& in)
+ {
+ std::auto_ptr<rgb> im (NULL);
+
+ std::auto_ptr<png::input> infile(png::input::create(in));
+
+ if (!infile.get()) return im;
+
+ im.reset(new image::rgb(infile->getWidth(), infile->getHeight()));
+
+ for (size_t i = 0, e = infile->getHeight(); i < e; ++i)
+ {
+ infile->readScanline(im->scanline(i));
+ }
+ return im;
+ }
rgb* read_swf_jpeg2_with_tables(jpeg::input* j_in)
// Create and read a new image, using a input object that
=== modified file 'libbase/image.h'
--- a/libbase/image.h 2008-07-23 18:53:51 +0000
+++ b/libbase/image.h 2008-08-05 07:50:38 +0000
@@ -253,6 +253,8 @@
/// For reading SWF JPEG3-style image data, like ordinary JPEG,
/// but stores the data in rgba format.
DSOEXPORT std::auto_ptr<rgba> readSWFJpeg3(gnash::IOChannel* in);
+
+ DSOEXPORT std::auto_ptr<rgb> readSWFPng(gnash::IOChannel& in);
} // namespace image
} // namespace gnash
=== modified file 'libbase/jpeg.cpp'
--- a/libbase/jpeg.cpp 2008-06-09 18:08:25 +0000
+++ b/libbase/jpeg.cpp 2008-08-05 10:16:20 +0000
@@ -14,14 +14,12 @@
#include "GnashException.h"
#include <sstream>
+#include <csetjmp>
extern "C" {
-
-// do we reall want to undefine HAVE_STDLIB_H here ??
#include <jpeglib.h>
}
-
namespace jpeg
{
@@ -92,7 +90,7 @@
if (src->m_start_of_file) {
// Treat this as a fatal error.
gnash::log_error("empty jpeg source
stream.");
- return FALSE;
+ return false;
}
// warn("jpeg end-of-stream");
@@ -122,7 +120,7 @@
src->m_pub.bytes_in_buffer = bytes_read;
src->m_start_of_file = false;
- return TRUE;
+ return true;
}
// Called by client when it wants to advance past some
@@ -258,7 +256,7 @@
}
/// Write the output buffer into the stream.
- static boolean empty_output_buffer(j_compress_ptr cinfo)
+ static boolean empty_output_buffer(j_compress_ptr cinfo)
{
rw_dest_IOChannel* dest = (rw_dest_IOChannel*)
cinfo->dest;
assert(dest);
@@ -547,8 +545,8 @@
{
public:
// State needed for output.
- struct jpeg_compress_struct m_cinfo;
- struct jpeg_error_mgr m_jerr;
+ jpeg_compress_struct m_cinfo;
+ jpeg_error_mgr m_jerr;
/// Constructor.
//
@@ -630,7 +628,7 @@
{
gnash::log_debug("Long jump: banzaaaaaai!");
_errorOccurred = msg;
- longjmp(_jmpBuf, 1);
+ std::longjmp(_jmpBuf, 1);
}
=== modified file 'libcore/impl.cpp'
--- a/libcore/impl.cpp 2008-07-03 23:45:54 +0000
+++ b/libcore/impl.cpp 2008-08-05 10:15:18 +0000
@@ -256,10 +256,6 @@
static movie_definition*
create_jpeg_movie(std::auto_ptr<IOChannel> in, const std::string& url)
{
- // FIXME: temporarly disabled
- //log_unimpl(_("Loading of jpegs"));
- //return NULL;
-
std::auto_ptr<image::rgb> im ( image::read_jpeg(in.get()) );
@@ -277,25 +273,30 @@
// Create a movie_definition from a png stream
// NOTE: this method assumes this *is* a png stream
+// TODO: The pp won't display PNGs for SWF7 or below.
static movie_definition*
-create_png_movie(std::auto_ptr<IOChannel> /*in*/, const std::string& /*url*/)
+createPNGMovie(std::auto_ptr<IOChannel> in, const std::string& url)
{
- log_unimpl(_("Loading of png"));
- return NULL;
-
-#if 0
- std::auto_ptr<image::rgb> im ( image::read_png(in.get()) );
-
- if ( ! im.get() )
- {
- log_error(_("Can't read png from %s"), url);
- return NULL;
- }
-
- BitmapMovieDefinition* mdef = new BitmapMovieDefinition(im, url);
- //log_debug(_("BitmapMovieDefinition %p created"), mdef);
- return mdef;
-#endif
+ assert (in.get());
+
+ try
+ {
+ std::auto_ptr<image::rgb> im(image::readSWFPng(*in));
+ if (!im.get())
+ {
+ log_error(_("Can't read png from %s"), url);
+ return NULL;
+ }
+
+ BitmapMovieDefinition* mdef = new BitmapMovieDefinition(im, url);
+ return mdef;
+
+ }
+ catch (ParserException& e)
+ {
+ log_error(_("Parsing error: %s"), e.what());
+ return NULL;
+ }
}
@@ -332,7 +333,7 @@
return GNASH_FILETYPE_JPEG;
}
- // This is the magic number for any JPEG format file
+ // This is the magic number for any PNG format file
if ((buf[0] == 137) && (buf[1] == 'P') && (buf[2] == 'N')) // buf[3] == 'G'
(we didn't read so far)
{
in->seek(0);
@@ -431,7 +432,7 @@
" movie in question is a png, for which we don't yet have the "
"concept of a 'loading thread'"));
}
- return create_png_movie(in, url);
+ return createPNGMovie(in, url);
}
else if ( type == GNASH_FILETYPE_SWF )
{
=== added file 'testsuite/media/png.png'
Binary files a/testsuite/media/png.png 1970-01-01 00:00:00 +0000 and
b/testsuite/media/png.png 2008-08-05 10:14:06 +0000 differ
=== modified file 'testsuite/misc-ming.all/Makefile.am'
--- a/testsuite/misc-ming.all/Makefile.am 2008-08-01 19:44:09 +0000
+++ b/testsuite/misc-ming.all/Makefile.am 2008-08-05 10:14:06 +0000
@@ -141,6 +141,7 @@
action_execution_order_test11 \
reverse_execute_PlaceObject2_test1 \
reverse_execute_PlaceObject2_test2 \
+ loadPNGTest \
loadMovieTest \
loadMovieTestRunner \
eventSoundTest1 \
@@ -1500,6 +1501,13 @@
-DTGTDIR='"$(abs_builddir)"' \
$(NULL)
+loadPNGTest_SOURCES = \
+ loadPNGTest.c \
+ $(NULL)
+loadPNGTest_LDADD = libgnashmingutils.la
+loadPNGTest.swf: loadPNGTest
+ ./loadPNGTest $(top_srcdir)/testsuite/media
+
loadMovieTest_SOURCES = \
loadMovieTest.c \
$(NULL)
=== added file 'testsuite/misc-ming.all/loadPNGTest.c'
--- a/testsuite/misc-ming.all/loadPNGTest.c 1970-01-01 00:00:00 +0000
+++ b/testsuite/misc-ming.all/loadPNGTest.c 2008-08-05 10:14:06 +0000
@@ -0,0 +1,205 @@
+/***********************************************************************
+ *
+ * Copyright (C) 2007 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ ***********************************************************************
+ *
+ * Test case for the MovieClip.loadMovie actionscript method
+ *
+ ***********************************************************************/
+
+/*
+ * run as ./loadMovieTest <mediadir>
+ *
+ * mediadir is where lynch.{jpg,swf}, green.{jpg,swf}
+ * and offspring.{jpg,swf} are located
+ *
+ */
+
+#include "ming_utils.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ming.h>
+
+// In version 7 or below PNGs shouldn't work.
+#define OUTPUT_VERSION 8
+#define OUTPUT_FILENAME "loadPNGTest.swf"
+
+void add_clip(SWFMovie mo, char* file, char* name, char* url, int x, int y);
+void add_button(SWFMovie mo, int x, int y, const char* label, SWFAction ac);
+void add_window(SWFMovie mo, int x, int y);
+SWFTextField get_label(const char* label, SWFFont font);
+
+
+const char* mediadir=".";
+
+void
+add_window(SWFMovie mo, int x, int y)
+{
+ SWFShape sh_window;
+ SWFFillStyle fstyle;
+ SWFMovieClip mc_window;
+ SWFDisplayItem it;
+
+ sh_window = newSWFShape();
+ fstyle = SWFShape_addSolidFillStyle(sh_window, 0,0,0,255);
+ SWFShape_setRightFillStyle(sh_window, fstyle);
+ SWFShape_movePenTo(sh_window, 170, 170);
+ SWFShape_drawLine(sh_window, -170, 0);
+ SWFShape_drawLine(sh_window, 0, -170);
+ SWFShape_drawLine(sh_window, 170, 0);
+ SWFShape_drawLine(sh_window, 0, 170);
+
+ mc_window = newSWFMovieClip();
+ SWFMovieClip_add(mc_window, (SWFBlock)sh_window);
+ SWFMovieClip_add(mc_window, (SWFBlock)newSWFAction(
+ "_root.xcheck(getBytesLoaded() < _root.getBytesLoaded());"
+ "_root.xcheck(getBytesTotal() < _root.getBytesTotal());"
+ ));
+ SWFMovieClip_nextFrame(mc_window); /* showFrame */
+
+ it = SWFMovie_add(mo, (SWFBlock)mc_window);
+ SWFDisplayItem_setName(it, "window");
+ SWFDisplayItem_moveTo(it, x, y);
+
+ SWFDisplayItem_addAction(it, compileSWFActionCode(
+ "_root.note('Click on \"Load PNG\" to load a PNG movie here.');"
+ ),
+ SWFACTION_ROLLOVER);
+
+ SWFDisplayItem_addAction(it, compileSWFActionCode(
+ "delete _level0.window.onMouseDown;"
+ ),
+ SWFACTION_ROLLOUT);
+
+}
+
+SWFTextField
+get_label(const char* label, SWFFont font)
+{
+ SWFTextField tf = newSWFTextField();
+ SWFTextField_setFont(tf, (void*)font);
+ SWFTextField_addChars(tf, "
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345689:.,/address@hidden");
+ SWFTextField_addString(tf, label);
+ return tf;
+}
+
+void
+add_button(SWFMovie mo, int x, int y, const char* label, SWFAction ac)
+{
+ SWFMovieClip btnclip = newSWFMovieClip();
+ SWFFont font = get_default_font(mediadir);
+ SWFDisplayItem it;
+ SWFTextField tf = get_label(label, font);
+
+ SWFMovieClip_add(btnclip, (SWFBlock)tf);
+ SWFMovieClip_nextFrame(btnclip);
+
+ it = SWFMovie_add(mo, (SWFBlock)btnclip);
+ SWFDisplayItem_moveTo(it, x, y);
+ SWFDisplayItem_addAction(it, ac, SWFACTION_PRESS);
+}
+
+int
+main(int argc, char** argv)
+{
+ SWFMovie mo;
+ SWFMovieClip dejagnuclip;
+ SWFDisplayItem it;
+
+ char file_png[256];
+ char url_png[256];
+
+ char png_action[256];
+
+ /*********************************************
+ *
+ * Initialization
+ *
+ *********************************************/
+
+ if ( argc>1 ) mediadir=argv[1];
+ else
+ {
+ fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
+ return 1;
+ }
+
+ sprintf(url_png, "%s/png.png", mediadir);
+
+
+ puts("Setting things up");
+
+ Ming_init();
+ Ming_useSWFVersion (OUTPUT_VERSION);
+ Ming_setScale(20.0); /* so we talk pixels */
+
+ mo = newSWFMovie();
+ SWFMovie_setDimension (mo, 800, 600);
+ SWFMovie_setRate (mo, 12.0);
+ SWFMovie_setBackground (mo, 255, 255, 255);
+
+ /*****************************************************
+ *
+ * Add Dejagnu clip
+ *
+ *****************************************************/
+
+ dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(mediadir),
10, 0, 0, 800, 600);
+ it = SWFMovie_add(mo, (SWFBlock)dejagnuclip);
+ SWFDisplayItem_moveTo(it, 0, 250);
+ SWFMovie_nextFrame(mo);
+
+ /*****************************************************
+ *
+ * Add the clips
+ *
+ *****************************************************/
+
+ sprintf(png_action, "_root.window.loadMovie(\"%s\");", url_png);
+
+ add_button(mo, 50, 100, "Load PNG", newSWFAction(png_action));
+
+ /*****************************************************
+ *
+ * Add the window clip
+ *
+ *****************************************************/
+
+ puts("Adding window");
+
+ add_window(mo, 600, 100);
+
+ add_actions(mo, "stop();");
+ SWFMovie_nextFrame(mo); /* showFrame */
+
+ /*****************************************************
+ *
+ * Output movie
+ *
+ *****************************************************/
+
+ puts("Saving " OUTPUT_FILENAME );
+
+ SWFMovie_save(mo, OUTPUT_FILENAME);
+
+ return 0;
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r9560: Add PNG-reading capabilities. This is only for PNG movies; there isn't,
Benjamin Wolsey <=