These pages are written by only Japanese.

Welcom to My Diary.com
最新の日記タイトル一覧カテゴリ別タイトル一覧トップへ戻る〜

こんばんわ♪ 現在は3月29日(金)22時46分。 10時を過ぎて、そろそろ深夜に入ります。


hns - 日記自動生成システム - Version 2.19.5 (色々 Fixed)

先月 2011年06月 来月
1 2 3 04
05 6 7 8 09 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
Namazu for hns による簡易全文検索です。
詳細は 詳細指定/ヘルプをご参照下さい。
検索式:

2011年06月21日(火)

SourceForge.JP の SVN => Git 移行

SWF Editor の開発メンバーが2人になったので、これを機に、
SourceForge.JP でのコード管理を SVN から Git に移行しました。
旧) http://svn.sourceforge.jp/svnroot/swfed/
新) git://git.sourceforge.jp/gitroot/swfed/swfed.git

移行手順:

cd ~/git
git svn clone --stdlayout svn+ssh://yoya@svn.sourceforge.jp/svnroot/swfed/
cd swfed
git remote add origin yoya@git.sourceforge.jp:/gitroot/swfed/swfed.git
git push --mirror origin
初め、--stdlayout を知らずに trunk や branches フォルダが git に登録されてしまい、やり直す為に Git のレポジトリを履歴毎全削除しました。

Git のリモートレポジトリを削除したい:

ググっても分からず、隣の席の人に聞いたら即答されました。
git push origin :master 
結構、試行錯誤しました。
  • git init して push > NG
  • git reset > NG (--hard で消せるとのツイートあり)
  • branch を切り替えて -d master > NG
  • -d -r master では? > NG
これ以外も色々試した気がしますが、忘れました。

2011年06月22日(水)

ビットマップ画像フォーマット毎のテスト素材

パレット形式だったり、24bit RGB 形式だったり、色んなパターンのテストが必要だけど。PHP GD を使うと簡単です。

パレット形式 PNG:

<?php
$im = imagecreate(100, 100);
$red = imagecolorallocate($im, 255, 0, 0);
imagefill($im, 0, 0, $red);
imagepng($im);

透明度付きパレット形式 PNG:

alpha を 1 にしないと透明度情報は入りません。
<?php
$im = imagecreate(100, 100);
$red = imagecolorallocatealpha($im, 255, 0, 0, 1);
imagefill($im, 0, 0, $red);
imagepng($im);

24bit RGB 形式 PNG:

<?php
$im = imagecreatetruecolor(100, 100);
$red = imagecolorallocate($im, 255, 0, 0);
imagefill($im, 0, 0, $red);
imagepng($im);

32bit RGBA 形式 PNG:

imagesavealpha が必要です☆
<?php
$im = imagecreatetruecolor(100, 100);
$red = imagecolorallocatealpha($im, 255, 0, 0, 0);
imagefill($im, 0, 0, $red);
imagesavealpha($im, true);
imagepng($im);

赤い画像:

見た目全部同じ赤い画像ですが、画像フォーマットが異なります。

2011年06月23日(木)

SWFEditor 0.42 release - replaceBitmapData

今回のリリースは replaceBitmapData の提供が目的です。
に対して、横サイズ100で色の青成分が255位の画像を入れ替えたい場合、
<?php
$swf = new SWFEditor();
$swf->input($swfdata);
$image_cond = array('width' => 100, 'blue' => 255);
$gifdata = file_get_contents('aria.gif');
$swf->replaceBitmapData($image_cond, $pngdata);
echo $swf->output();
を実行すると、

が出力されます。

画像形式を選ばない:

今まで、ビットマップ画像のファイル形式に応じて、replaceJpegData, replacePNGData, replaceGIFData を使い分けましたが、replaceBitmapData は、どの画像形式を渡しても動作します。
内部的には、画像データの先頭3,4バイトで画像形式を判別して、replaceJpegData 等の対応するメソッドを呼んでいるだけです。

条件指定が増えた:

SWF 内部の入れ替え対象の画像を画像IDで指定する方式だと、SWF をパブリッシュする毎に ID が替わる可能性があって管理が面倒ですが、replaceBitmapData では画像サイズと画像の色の組み合わせで指定する事が出来ます。 ただし、画像の色指定は少し重た目 *1 なので、可能であればサイズ指定をお勧めします。

*1: SWF 内部の画像ピクセルを取りだすのに、zlib 伸長の処理が必要な為

2011年06月24日(金)

SWFEditor 0.43 release - replaceActionStrings memory leak fix

0.43 をリリースしました。memory leak の修正対応です。 SWFEditor は-DMALLOC_DEBUG オプションを付けてコンパイルすると、memory leak を洗い出せます。そのテストで2つ問題を見つけ、修正しました。

問題1 (replaceShapeData):

swf_object_replace_shapedata: fallback to read old shape data
XXX (6) ptr=0x99db138 (/home/yoya/git/swfed/src/swf_tag.c, 107)
replaceShapeData の扱うデータ形式が 0.37 から 0.38 で変わったので、0.37 のデータも受理出来るように fallback 処理を入れていますが、そこで free せずにポインタを上書きしてました。

問題2 (replaceActionStrings):

XXX (204928) ptr=0xb40eb48 (/home/yoya/git/swfed/src/bitstream.c, 15)
XXX (204929) ptr=0xb49af90 (/home/yoya/git/swfed/src/bitstream.c, 69)
実はこっちがより深刻で…
bitstream_open で確保する bitstream 管理データ(24yte+α)の free 忘れなので、全部の bitstream_open と close の関係を洗い直す作業 *1 をしたら、action tag detail build 処理に close し忘れを見つけました。
現状、この処理が動くのは rebuild と replaceActionStrings の2種類で、rebuild は基本デバッグや入稿処理とかで使われるとして、replaceActionStrings の方は頻繁に呼ぶ処理として使うはずなので、非常にマズイです。 これらのメソッドを呼んだ回数 x (24byte + α) の memory leak が(その後ろで output を呼んだタイミングで)発生します。

*1: bitstream_open の後、関数のあちこちにある return で確実に close してるのかをチェックするだけですが

setShapeAdjustMode SHAPE_BITMAP_MATRIX_RESCALE の副作用

複数の画像が貼り付けられている SWF で、replace 系メソッドで入れ替えた画像以外も巻き添えで Rescale される現象に遭遇しました。
該当の SWF ファイルの内部構造を調べてみたら、スケール変換の行列を持つ DefineShape タグを全画像で共通に持つのですが、変換行列自体は独立に持つはずなので、謎です。調査中。

2011年06月25日(土)

ActionPush の複数値指定

Flash SWF の ActionScript2 Bytecode に ActionPush(0x96) という、実行マシンスタックに値を積む命令がありまして、
IO_SWF と SWFEditor の replaceActionStrings がこの ActionPush の仕様を満たしていないので修正中です。
情報 thx > @yoshikids

勘違い:

ActionPush は例えば文字列を渡す時は、↓こういうフォーマットだと思っていましたが、
Code |Length|Type|  String  |StringEnd|
0x96 |  ??? | 0  |   ???    |   0     |
             <-------  Length  ------->
仕様書を読むと。
ActionPush pushes one or more values onto the stack.
The Type field specifies the type of the value to be pushed.
とありまして、複数の値を一度に Push 出来るようです。
つまり、↓こっちのイメージが正しいです。
|Length|Type|  String  |StringEnd|Type| something |
|  ??? | 0  |   ???    |   0     |  ? |   ???     |
       <----------------  Length  ---------------->
面倒なのは、情報要素毎に Type 指定するので、任意の型が混在した配列を表現できる事です。
1つが文字列だからといって他のデータが文字列であるとは限らないので、このバイナリを再構築するには、全 Type について処理する必要があります。

イメージを作ってみる。:

a = 1;
b = 2;
c = 3;
コンパイルすると以下のような SWF バイナリが出来ます。
00000000  46 57 53 04 4b 00 00 00  70 00 09 60 00 00 96 00  |FWS.K...p..`....|
00000010  00 0a 01 00 43 02 ff ff  ff 3f 03 28 00 00 00 96  |....C....?.(....|
00000020  03 00 00 61 00 96 03 00  00 31 00 1d 96 03 00 00  |...a.....1......|
00000030  62 00 96 03 00 00 32 00  1d 96 03 00 00 63 00 96  |b.....2......c..|
00000040  03 00 00 33 00 1d 00 40  00 00 00                 |...3...@...|
swftools の swfdump で逆アセンブルして確認
[00c]        40 DOACTION
                 (    3 bytes) action: Push String:"a"
                 (    3 bytes) action: Push String:"1"
                 (    0 bytes) action: SetVariable
                 (    3 bytes) action: Push String:"b"
                 (    3 bytes) action: Push String:"2"
                 (    0 bytes) action: SetVariable
                 (    3 bytes) action: Push String:"c"
                 (    3 bytes) action: Push String:"3"
                 (    0 bytes) action: SetVariable
                 (    0 bytes) action: End
この中から Action Push のイメージを抜き出すと、この辺り。
00000010                                                96  |               .|
                                                        ~~ 
                                                        P (Push)
00000020  03 00 00 61 00 96 03 00  00 31 00 1d 96 03 00 00  |...a.....1......|
          ~~~~  ~~ ~~~~~ ~~ ~~~~~  ~~ ~~~~~ ~~  
           len type 'a'  AP  len type  '1'  SV (SetVariables)
(意味的に正しいか自信ないけど、今回はバイナリ形式しか考えないとして)
a と 1 を一緒に push するバイナリイメージに書き換えてみます。
(SWF Header の FileLength と Tag HeaderRecords の Length も書き換えます)
00000010                                                96  |               .|
                                                        ~~ 
                                                        P (Push)
00000020  06 00 00 61 00 00 31 00  1d 96 03 00 00 62 00 96  |...a..1......b..|
          ~~~~~ ~~ ~~~~~ ~~ ~~~~~  ~~ 
           len type 'a' type '1'   SV (SetVariables)
もう一度、swfdump で
[00c]        40 DOACTION
                 (    6 bytes) action: Push String:"a" String:"1"
                 (    0 bytes) action: SetVariable
                 (    3 bytes) action: Push String:"b"
                 (    3 bytes) action: Push String:"2"
                 (    0 bytes) action: SetVariable
                 (    3 bytes) action: Push String:"c"
                 (    3 bytes) action: Push String:"3"
                 (    0 bytes) action: SetVariable
                 (    0 bytes) action: End
テスト用サンプルの作り方が分かったので、これで実装できます。

2011年06月26日(日)

phpopengl のフォーラムで質問が来てました。

2011-06-26 08:23:24 UTC
Hi Yoya I am an Australian who fools around with PHP as a hobby.
I have just downloaded the openGL package and am attempting to get it going.
It seems really old from what I read in the glut32.txt document.
I want to be able to use openGL to render a rotating sphere for a game idea I am occasionally working on.
Cheers 
訳すると、こんな感じ。
よやさん。
私は趣味でPHPを触ってるオーストラリア人です。
openGLパッケージをダウンロードして試してます。
glut32.txt より実際には古いみたいです。
ゲームで回転する球体をレンダリングするのに OpenGL を使いたいです。
それでは。
ふむ。
どんな環境でどのバージョンのどのAPIを使いたいのか気になりますが、
とりあえず、最新版をダウンロードして glut32.txt と違う状況を調べて、
自分の所がこんな環境で、こういう感じですが、そちらはどうですか?
と聞くのが親切かしら。

glut32.txt:

php_opengl-0.2.0-win.zip の中に glut32.txt を見つけました。
CHANGES/FIXES:

    (Oct 4, '01)
    x  Fixed bug in glutEnterGameMode() that caused new windows to not 
       be in "fullscreen" mode, so they got window decorations.
    (Oct 3, '01)
    x  Fixed bug in getVisualInfoFromString(): visuals not reloaded on 
<略>
どちらの関数も 0.2.0 の tarball どころか cvs にさえ存在しません。(そういえば glutEnterGameMode 欲しくて実装始めてました)
確かにドキュメントが先走ってますね。glut32.txt は cvs 管理もされてないし、どうなってるんだろう。
作者の手元にだけ実装の進んだコードがある。みたいな感じかな。

2011年06月27日(月)

SWFEditor 0.44 release - replaceActionStrings push multiple data fix

0.44 をリリースしました。replaceActionStrings の不具合対応です。

IO_SWF 2.0.5 release

2.0.5 をリリースしました。SWF Editor と同じく replaceActionStrings の不具合修正です。

これで、7 日分だよ〜。

タイトル一覧
カテゴリ分類
Database
JXTA
Java
XML
awm
bookmark
keyword
memo
news
research
Powered by hns-2.19.5, HyperNikkiSystem Project