📄 swf.h
字号:
/* 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*/#if 0#ifndef SWF_H_INCLUDED#define SWF_H_INCLUDED#include <stdio.h>#include "blocktypes.h"typedef unsigned char byte;extern void (*SWF_warn)(const char *msg, ...);extern void (*SWF_error)(const char *msg, ...);void setSWFWarnFunction(void (*error)(const char *msg, ...));void setSWFErrorFunction(void (*error)(const char *msg, ...));void SWF_assert(int c); /* a generic output method. specific instances dump output to file, send to stdout, etc. */typedef void (*SWFByteOutputMethod)(byte b, void *data);void methodWriteUInt16(int i, SWFByteOutputMethod method, void *data);void methodWriteUInt32(int i, SWFByteOutputMethod method, void *data);void fileOutputMethod(byte b, void *data);/* we dig opaque types */ /* SWFBlock is the parent for all classes in this directory */typedef struct SWFBlock_s* SWFBlock;int completeSWFBlock(SWFBlock block);void destroySWFBlock(SWFBlock block);int writeSWFBlockToMethod(SWFBlock block, SWFByteOutputMethod method, void *data);void SWFBlock_setDefined(SWFBlock block);byte SWFBlock_isDefined(SWFBlock block);SWFBlocktype SWFBlock_getType(SWFBlock block); /* SWFInput */typedef struct SWFInput_s *SWFInput;int SWFInput_length(SWFInput input);void SWFInput_rewind(SWFInput input);int SWFInput_tell(SWFInput input);void SWFInput_seek(SWFInput input, long offset, int whence);int SWFInput_eof(SWFInput input);SWFInput newSWFInput_file(FILE *f);SWFInput newSWFInput_stream(FILE *f);SWFInput newSWFInput_buffer(unsigned char *buffer, int length);SWFInput newSWFInput_allocedBuffer(unsigned char *buffer, int length); /* SWFOutput */typedef struct SWFOutput_s * SWFOutput;SWFOutput newSWFOutput();SWFOutput newSizedSWFOutput(int size);void destroySWFOutput(SWFOutput out);int SWFOutput_length(SWFOutput out);void SWFOutput_byteAlign(SWFOutput out);void SWFOutput_writeUInt16(SWFOutput out, int data);void SWFOutput_writeToMethod(SWFOutput out, SWFByteOutputMethod method, void *data); /* SWFRect */typedef struct SWFRect_s * SWFRect;SWFRect newSWFRect(int minX, int maxX, int minY, int maxY);void destroySWFRect(SWFRect rect);void SWFOutput_writeRect(SWFOutput output, SWFRect rect);int SWFRect_getWidth(SWFRect r);int SWFRect_getHeight(SWFRect r); /* SWFCharacter *//* everything with a character ID is an SWFCharacter */typedef struct SWFCharacter_s * SWFCharacter;/* this is a silly hack to track blocks which are dependent on others. Would be nice to have this in the ming layer above instead */void SWFCharacter_addDependency(SWFCharacter character, SWFBlock dependency);SWFBlock *SWFCharacter_getDependencies(SWFCharacter character);int SWFCharacter_getNDependencies(SWFCharacter character);void SWFCharacter_clearDependencies(SWFCharacter character);int SWFCharacter_getScaledWidth(SWFCharacter character);int SWFCharacter_getScaledHeight(SWFCharacter character);int SWFBlock_isCharacter(SWFBlock block); /* SWFBitmap */typedef struct SWFBitmap_s *SWFBitmap;void destroySWFBitmap(SWFBlock block);int SWFBitmap_getWidth(SWFBitmap b);int SWFBitmap_getHeight(SWFBitmap b);SWFBitmap newSWFBitmap_fromInput(SWFInput input); /* SWFDBLBitmap */typedef struct SWFDBLBitmap_s *SWFDBLBitmap;SWFDBLBitmap newSWFDBLBitmap(FILE *f);SWFDBLBitmap newSWFDBLBitmap_fromInput(SWFInput input); /* SWFJpegBitmap */typedef struct SWFJpegBitmap_s *SWFJpegBitmap;typedef struct SWFJpegWithAlpha_s *SWFJpegWithAlpha;SWFJpegBitmap newSWFJpegBitmap(FILE *f);SWFJpegBitmap newSWFJpegBitmap_fromInput(SWFInput input);SWFJpegWithAlpha newSWFJpegWithAlpha(FILE *f, FILE *alpha);SWFJpegWithAlpha newSWFJpegWithAlpha_fromInput(SWFInput input, SWFInput alpha); /* SWFGradient */typedef struct SWFGradient_s *SWFGradient;SWFGradient newSWFGradient();void destroySWFGradient(SWFGradient gradient);void SWFGradient_addEntry(SWFGradient gradient, float ratio, byte r, byte g, byte b, byte a); /* SWFMatrix */typedef struct SWFMatrix_s *SWFMatrix;SWFMatrix newSWFMatrix(float a, float b, float c, float d, int x, int y);void destroySWFMatrix(SWFMatrix matrix);SWFMatrix SWFMatrix_set(SWFMatrix m, float a, float b, float c, float d, int x, int y);void SWFMatrix_clearTranslate(SWFMatrix m);void SWFMatrix_clearTransform(SWFMatrix m);float SWFMatrix_getScaleX(SWFMatrix m);float SWFMatrix_getRotate0(SWFMatrix m);float SWFMatrix_getRotate1(SWFMatrix m);float SWFMatrix_getScaleY(SWFMatrix m);int SWFMatrix_getTranslateX(SWFMatrix m);int SWFMatrix_getTranslateY(SWFMatrix m); /* SWFFont */typedef struct SWFFont_s *SWFFont;SWFFont newSWFFont();SWFFont loadSWFFontFromFile(FILE *file);void destroySWFFont(SWFBlock block);int SWFFont_getScaledStringWidth(SWFFont font, const unsigned char *string);short SWFFont_getScaledAscent(SWFFont font);short SWFFont_getScaledDescent(SWFFont font);short SWFFont_getScaledLeading(SWFFont font); /* SWFText */typedef struct SWFText_s *SWFText;SWFText newSWFText();SWFText newSWFText2();void destroySWFText(SWFBlock block);void SWFText_setFont(SWFText text, SWFBlock font);void SWFText_setScaledHeight(SWFText text, int height);void SWFText_scaledMoveTo(SWFText text, int x, int y);void SWFText_setColor(SWFText text, byte r, byte g, byte b, byte a);void SWFText_addString(SWFText text, const char *string, int *advance);void SWFText_addUTF8String(SWFText text, const char *string, int *advance);void SWFText_setSpacing(SWFText text, float spacing);int SWFText_getScaledStringWidth(SWFText text, const char *string);int SWFText_getScaledUTF8StringWidth(SWFText text, const char *string);short SWFText_getScaledAscent(SWFText text);short SWFText_getScaledDescent(SWFText text);short SWFText_getScaledLeading(SWFText text);/* deprecated: */#define SWFText_setXY(t,x,y) SWFText_moveTo((t),(x),(y)) /* SWFBrowserFont */typedef struct SWFBrowserFont_s *SWFBrowserFont;SWFBrowserFont newSWFBrowserFont(char *name);void destroySWFBrowserFont(SWFBlock block); /* SWFTextField */typedef struct SWFTextField_s *SWFTextField;#define SWFTEXTFIELD_ONMASK 0x2085 /* on bits */#define SWFTEXTFIELD_OFFMASK 0x7BFF /* off bits */#define SWFTEXTFIELD_HASFONT (1<<0) /* font and size given */#define SWFTEXTFIELD_HASLENGTH (1<<1)#define SWFTEXTFIELD_HASCOLOR (1<<2)#define SWFTEXTFIELD_NOEDIT (1<<3)#define SWFTEXTFIELD_PASSWORD (1<<4)#define SWFTEXTFIELD_MULTILINE (1<<5)#define SWFTEXTFIELD_WORDWRAP (1<<6)#define SWFTEXTFIELD_HASTEXT (1<<7) /* initial text present */#define SWFTEXTFIELD_USEFONT (1<<8)#define SWFTEXTFIELD_HTML (1<<9)#define SWFTEXTFIELD_DRAWBOX (1<<11)#define SWFTEXTFIELD_NOSELECT (1<<12)#define SWFTEXTFIELD_HASLAYOUT (1<<13) /* align, margin, lspace, indent */#define SWFTEXTFIELD_AUTOSIZE (1<<14) /* SWF6 */typedef enum{ SWFTEXTFIELD_ALIGN_LEFT = 0, SWFTEXTFIELD_ALIGN_RIGHT = 1, SWFTEXTFIELD_ALIGN_CENTER = 2, SWFTEXTFIELD_ALIGN_JUSTIFY = 3} SWFTextFieldAlignment;SWFTextField newSWFTextField();void destroySWFTextField(SWFBlock block);void SWFTextField_setFont(SWFTextField field, SWFBlock font);void SWFTextField_setScaledBounds(SWFTextField field, int width, int height);void SWFTextField_setFlags(SWFTextField field, int flags);void SWFTextField_setColor(SWFTextField field, byte r, byte g, byte b, byte a);void SWFTextField_setVariableName(SWFTextField field, const char *name);void SWFTextField_addString(SWFTextField field, const char *string);void SWFTextField_addUTF8String(SWFTextField field, const char *string);void SWFTextField_setScaledFontHeight(SWFTextField field, int height);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -