// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // encoder.hsp // Last Modified:2006/08/30-00:15. // ふじこ用画像圧縮ツール // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ファイルリスト取得して sdim list, 3200 dirlist list, "img\\*.bmp", 0 // ウィンドウに展開 notesel list repeat notemax pos cnt * 16 noteget file, cnt picload "img\\" + file, 1 loop // 画像の幅と高さ w = 16 * notemax h = 16 // 書き込み位置 bitindex = 0 // 出力用バッファ sdim out, 64 * notemax // 圧縮 // 圧縮フォーマット: // 縦方向にサーチして隣接色が同じならまとめて記憶していくという、よくある方法 // ただそれだとちょっと無駄が多いので、連結長が2以下なら情報を次の上位ビットに含めてしまう // 圧縮率のほうは対して高くない // 素直に1文字に4Bitずつ割り当てたほうが楽だったし、キャラ画像の背景透過処理との相性との関係が悪い // だめだめじゃん // // 詳細は割愛 preRed = 255 repeat w * h x = cnt / h y = cnt \ h pget x, y if( ginfo_r == preRed ) { chanks++ } else { assert ( chanks + 0x20 ) < 0x7f preRed = ginfo_r if( chanks > 1 ) { poke out, bitIndex, chanks + 0x20 bitIndex++ chanks = 0 } else { chanks = 0x20 + 0x20 * chanks } } loop bsave "out", out, strlen( out ) repeat notemax color 0xff pos cnt * 16, 16 mes cnt loop