⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mingpp.h

📁 flash swf file player
💻 H
📖 第 1 页 / 共 2 页
字号:
/*    Ming, an SWF output library    Copyright (C) 2001  Opaque Industries - http://www.opaque.net/    This library is free software; you can redistribute it and/or    modify it under the terms of the GNU Lesser General Public    License as published by the Free Software Foundation; either    version 2.1 of the License, or (at your option) any later version.    This library 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    Lesser General Public License for more details.    You should have received a copy of the GNU Lesser General Public    License along with this library; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/#include <stdio.h>#include <string.h>/* mask the c type names so that we can replace them with classes.   weird, but it works.  (on gcc, anyway..) */extern "C"{  #define SWFShape        c_SWFShape  #define SWFMovie        c_SWFMovie  #define SWFDisplayItem  c_SWFDisplayItem  #define SWFFill         c_SWFFill  #define SWFCharacter    c_SWFCharacter  #define SWFBlock        c_SWFBlock  #define SWFSprite       c_SWFSprite  #define SWFMovieClip    c_SWFMovieClip  #define SWFBitmap       c_SWFBitmap  #define SWFGradient     c_SWFGradient  #define SWFMorph        c_SWFMorph  #define SWFText         c_SWFText  #define SWFFont         c_SWFFont  #define SWFTextField    c_SWFTextField  #define SWFAction       c_SWFAction  #define SWFButton       c_SWFButton  #define SWFSound        c_SWFSound  #define SWFInput        c_SWFInput  #include <ming.h>  #undef SWFShape  #undef SWFMovie  #undef SWFDisplayItem  #undef SWFFill  #undef SWFCharacter  #undef SWFBlock  #undef SWFSprite  #undef SWFMovieClip  #undef SWFBitmap  #undef SWFGradient  #undef SWFMorph  #undef SWFFont  #undef SWFText  #undef SWFTextField  #undef SWFAction  #undef SWFButton  #undef SWFSound  #undef SWFInput}#define SWF_DECLAREONLY(classname) \	private: \	classname(const classname&); \	const classname& operator=(const classname&)/*  SWFInput  */class SWFInput{ public:  c_SWFInput input;  SWFInput(FILE *f)    { this->input = newSWFInput_file(f); }  SWFInput(unsigned char *buffer, int length)    { this->input = newSWFInput_buffer(buffer, length); }  SWFInput(unsigned char *buffer, int length, int alloced)  {    if(alloced)      this->input = newSWFInput_allocedBuffer(buffer, length);    else      this->input = newSWFInput_buffer(buffer, length);  }  virtual ~SWFInput() { destroySWFInput(this->input); }  SWF_DECLAREONLY(SWFInput);  SWFInput();};/*  SWFBlock  */class SWFBlock{ public:  virtual c_SWFBlock getBlock()    { return NULL; }};/*  SWFCharacter  */class SWFCharacter : public SWFBlock{ public:  c_SWFCharacter character;  float getWidth()    { return SWFCharacter_getWidth(this->character); }  float getHeight()    { return SWFCharacter_getHeight(this->character); }  virtual c_SWFBlock getBlock()    { return NULL; }  SWFCharacter() {} //needed for base classing  SWF_DECLAREONLY(SWFCharacter);};/*  SWFAction  */class SWFAction : public SWFBlock{ public:  c_SWFAction action;  SWFAction(const char *script)    { this->action = compileSWFActionCode(script); }  // movies, buttons, etc. destroy the c_SWFAction..  virtual ~SWFAction() {}  c_SWFBlock getBlock()    { return (c_SWFBlock)this->action; }  SWF_DECLAREONLY(SWFAction);  SWFAction();};/*  SWFDisplayItem  */class SWFDisplayItem{ public:  c_SWFDisplayItem item;  SWFDisplayItem(c_SWFDisplayItem item)    { this->item = item; }  virtual ~SWFDisplayItem()    { }  void rotate(float degrees)    { SWFDisplayItem_rotate(this->item, degrees); }  void rotateTo(float degrees)    { SWFDisplayItem_rotateTo(this->item, degrees); }  void getRotation(float *degrees)    { SWFDisplayItem_getRotation(this->item, degrees); }  void move(float x, float y)    { SWFDisplayItem_move(this->item, x, y); }  void moveTo(float x, float y)    { SWFDisplayItem_moveTo(this->item, x, y); }  void getPosition(float *x, float *y)    { SWFDisplayItem_getPosition(this->item, x, y); }  void scale(float xScale, float yScale)    { SWFDisplayItem_scale(this->item, xScale, yScale); }  void scale(float scale)    { SWFDisplayItem_scale(this->item, scale, scale); }  void scaleTo(float xScale, float yScale)    { SWFDisplayItem_scaleTo(this->item, xScale, yScale); }  void scaleTo(float scale)    { SWFDisplayItem_scaleTo(this->item, scale, scale); }  void getScale(float *xScale, float *yScale)    { SWFDisplayItem_getScale(this->item, xScale, yScale); }  void skewX(float skew)    { SWFDisplayItem_skewX(this->item, skew); }  void skewXTo(float skew)    { SWFDisplayItem_skewXTo(this->item, skew); }  void skewY(float skew)    { SWFDisplayItem_skewY(this->item, skew); }  void skewYTo(float skew)    { SWFDisplayItem_skewYTo(this->item, skew); }  void getSkew(float *xSkew, float *ySkew)    { SWFDisplayItem_getSkew(this->item, xSkew, ySkew); }  int getDepth()    { return SWFDisplayItem_getDepth(this->item); }  void setDepth(int depth)    { SWFDisplayItem_setDepth(this->item, depth); }  void remove()    { SWFDisplayItem_remove(this->item); }  void setName(const char *name)    { SWFDisplayItem_setName(this->item, name); }  void setRatio(float ratio)    { SWFDisplayItem_setRatio(this->item, ratio); }  void addColor(int r, int g, int b, int a=0)    { SWFDisplayItem_setColorAdd(this->item, r, g, b, a); }  void multColor(float r, float g, float b, float a=1.0)    { SWFDisplayItem_setColorMult(this->item, r, g, b, a); }  void addAction(SWFAction *action, int flags)    { SWFDisplayItem_addAction(this->item, action->action, flags); }  SWF_DECLAREONLY(SWFDisplayItem);  SWFDisplayItem();};/*  SWFSound  */class SWFSound{ public:  c_SWFSound sound;  SWFSound(FILE *file, int flags)    { this->sound = newSWFSound(file, flags); }  SWFSound(SWFInput *input, int flags)    { this->sound = newSWFSound_fromInput(input->input, flags); }  SWFSound(char *filename, int flags)    { this->sound = newSWFSound(fopen(filename, "rb"), flags); }  virtual ~SWFSound()    { destroySWFSound(this->sound); }  SWF_DECLAREONLY(SWFSound);  SWFSound();};/*  SWFMovie  */class SWFMovie{ public:  c_SWFMovie movie;  SWFMovie()    { this->movie = newSWFMovie(); }  virtual ~SWFMovie()    { destroySWFMovie(this->movie); }  void setRate(float rate)    { SWFMovie_setRate(this->movie, rate); }  void setDimension(float x, float y)    { SWFMovie_setDimension(this->movie, x, y); }  void setNumberOfFrames(int nFrames)    { SWFMovie_setNumberOfFrames(this->movie, nFrames); }  /* aka */  void setFrames(int nFrames)    { SWFMovie_setNumberOfFrames(this->movie, nFrames); }  void setBackground(int r, int g, int b)    { SWFMovie_setBackground(this->movie, r, g, b); }  void setSoundStream(SWFSound *sound)    { SWFMovie_setSoundStream(this->movie, sound->sound); }  SWFDisplayItem *add(SWFBlock *character)    { return new SWFDisplayItem(SWFMovie_add(this->movie, character->getBlock())); }  void remove(SWFDisplayItem *item)    { SWFMovie_remove(this->movie, item->item); }  void nextFrame()    { SWFMovie_nextFrame(this->movie); }  void labelFrame(const char *label)    { SWFMovie_labelFrame(this->movie, label); }  int output(int level=-1)    { return SWFMovie_output(this->movie, fileOutputMethod, stdout, level); }  int save(const char *filename, int level=-1)  {    FILE *fp = fopen(filename, "wb");    const int result = SWFMovie_output(this->movie, fileOutputMethod, fp, level);    fclose(fp);    return result;  }  SWF_DECLAREONLY(SWFMovie);};/*  SWFFill  */class SWFFill{ public:  c_SWFFill fill;  SWFFill(c_SWFFill fill)    { this->fill = fill; }  // shape destroys c_SWFFill object  virtual ~SWFFill() {}  void skewX(float x)    { SWFFill_skewX(this->fill, x); }  void skewXTo(float x)    { SWFFill_skewXTo(this->fill, x); }  void skewY(float y)    { SWFFill_skewY(this->fill, y); }  void skewYTo(float y)    { SWFFill_skewYTo(this->fill, y); }  void scaleX(float x)    { SWFFill_scaleX(this->fill, x); }  void scaleXTo(float x)    { SWFFill_scaleXTo(this->fill, x); }  void scaleY(float y)    { SWFFill_scaleY(this->fill, y); }  void scaleYTo(float y)    { SWFFill_scaleYTo(this->fill, y); }  void scale(float x, float y)    { SWFFill_scaleXY(this->fill, x, y); }  void scale(float scale)    { SWFFill_scaleXY(this->fill, scale, scale); }  void scaleTo(float x, float y)    { SWFFill_scaleXYTo(this->fill, x, y); }  void scaleTo(float scale)    { SWFFill_scaleXYTo(this->fill, scale, scale); }  void rotate(float degrees)    { SWFFill_rotate(this->fill, degrees); }  void rotateTo(float degrees)    { SWFFill_rotateTo(this->fill, degrees); }  void move(float x, float y)    { SWFFill_move(this->fill, x, y); }  void moveTo(float x, float y)    { SWFFill_move(this->fill, x, y); }  SWF_DECLAREONLY(SWFFill);  SWFFill();};/*  SWFGradient  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -