static void Main(string[] args)
{
var color_index = new List();
color_index.Add(Color.Transparent);
var pixel_data = new List();
var bmp = new Bitmap("import.bmp");
for (int y = 0; y < bmp.Height; y++)
{
for (int x = 0; x < bmp.Width; x++)
{
var c = bmp.GetPixel(x, y);
if (!color_index.Contains(c))
{
color_index.Add(c);
}
var index = color_index.IndexOf(c);
pixel_data.Add(index);
}
}
using (var w = new StreamWriter("input.txt", false, Encoding.GetEncoding("Shift_JIS")))
{
using (var r = new StreamReader("ConvCode.txt"))
{
w.Write(r.ReadToEnd());
}
w.WriteLine("@COLOR_INDEX");
w.WriteLine("'さいず");
var max_index = color_index.Count;
if (max_index >= 256)
{
max_index = 255;
}
w.WriteLine("DATA " + max_index);
for (int i = 0; i < max_index; i++)
{
var c = color_index[i];
w.WriteLine("DATA \"" + string.Format("{0:X2}{1:X2}{2:X2}", c.R, c.G, c.B) + "\"");
}
w.WriteLine("@IMPORT_DATA");
w.WriteLine("'さいず");
w.Write("DATA " + bmp.Width.ToString() + "," + bmp.Height.ToString());
var length = 255;
foreach (var item in pixel_data)
{
if (length > 90)
{
w.Write("\nDATA ");
length = 5;
}
if (length > 5)
{
w.Write(",");
}
var index = item;
if (index > 255)
{
index = 255;
}
length += index.ToString().Length + 1;
w.Write(index);
}
}
}
ACLS
CLEAR
@COLOR_INDEX_SET
RESTORE @COLOR_INDEX
READ LENGTH
FOR I=0 TO LENGTH-1
READ RD$
COLSET "GRP",I,RD$
NEXT
@DRAW
RESTORE @IMPORT_DATA
READ WIDTH,HEIGHT
FOR Y=0 TO HEIGHT-1
FOR X=0 TO WIDTH-1
READ C
GPSET X,Y,C
NEXT
NEXT
単純に256色全開つかってCOLSETしてピクセルをGPSETで打ってくだけもの。
出力結果TEXT
そんな感じでできた出力結果がこんなの
長いので一部省略しちゃうんで、そのままじゃ動きません
ACLS
CLEAR
@COLOR_INDEX_SET
RESTORE @COLOR_INDEX
READ LENGTH
FOR I=0 TO LENGTH-1
READ RD$
COLSET "GRP",I,RD$
NEXT
@DRAW
RESTORE @IMPORT_DATA
READ WIDTH,HEIGHT
FOR Y=0 TO HEIGHT-1
FOR X=0 TO WIDTH-1
READ C
GPSET X,Y,C
NEXT
NEXT
@COLOR_INDEX
'さいず
DATA 255
DATA "FFFFFF"
DATA "E8A8A8"
DATA "E4A2A1"
DATA "FC9EA2"
DATA "EFA2A6"
DATA "D8ACB4"
DATA "D5BABC"
DATA "B4C2C4"
DATA "9CCEDE"
DATA "93D2E7"
DATA "93CEE1"
DATA "BCCADC"
DATA "E8B4B2"
DATA "F8B4B3"
DATA "F8ACB4"
DATA "ECB2BC"
DATA "D8B4B7"
(~中略~)
DATA "70AEBC"
DATA "AFB5B7"
DATA "548694"
DATA "F4FBF2"
DATA "606260"
DATA "94A2B4"
DATA "B47C7C"
DATA "545753"
DATA "534C4A"
DATA "57524C"
DATA "ACC6C4"
@IMPORT_DATA
'さいず
DATA 64,64
DATA 1,2,3,3,3,3,4,1,5,6,7,8,9,9,10,11,6,12,13,13,14,12,15,16,17,18,8,19,20,20,21,21,22,22
DATA 19,23,20,9,24,20,24,20,9,9,9,24,24,24,20,20,24,9,24,24,10,20,20,20,24,20,24,24,24,9,25
DATA 1,4,3,3,26,27,12,12,6,11,28,9,9,8,11,29,30,31,31,31,31,31,6,7,28,28,18,22,22,32,32,28
DATA 28,22,22,22,20,20,20,10,20,20,20,9,20,9,24,20,20,9,24,9,9,20,20,20,20,20,20,33,24,24,24
DATA 16,16,27,27,27,14,12,34,31,35,36,28,18,8,37,38,29,39,30,40,30,40,40,41,42,43,44,45,45
DATA 45,45,45,45,46,47,28,28,22,22,22,21,20,20,20,20,24,9,24,24,20,24,24,9,24,24,9,20,24,20
DATA 24,24,20,24,9,48,16,15,15,34,34,34,39,40,49,50,28,18,18,51,52,53,54,53,55,55,55,39,56
DATA 57,58,59,59,59,57,59,60,57,61,60,61,62,45,47,32,22,22,22,20,24,9,10,24,24,24,24,10,20
DATA 10,24,24,24,24,24,20,20,24,9,24,37,37,34,31,30,30,39,39,55,54,52,63,28,18,52,64,65,66
DATA 65,65,65,65,65,67,57,57,57,57,57,68,57,69,57,57,57,57,59,57,59,70,46,32,32,21,22,20,24
DATA 9,9,9,24,20,20,24,24,33,24,24,10,24,20,20,20,24,17,36,29,39,39,54,54,53,65,71,72,52,73
DATA 74,75,64,64,76,77,64,76,65,77,69,77,69,78,79,79,78,78,78,78,69,69,69,69,57,57,57,59,61
DATA 46,28,32,19,22,24,24,9,20,20,20,20,24,24,24,24,10,20,20,20,24,20,28,11,80,54,54,65,66
(~中略~)
DATA 138,40,85,107,101,29,39,49,121,140,195,253,129,129,195,129,252,129,129,253,129,253,251
DATA 129,253,195,225,149,29,39,39,30,39,41,12,138,144,105,147,42,42,95,7,82,81,103,28,22,20
DATA 20,24,9,10,22,20,18,32,28,254,254,110,111,101,101,105,39,41,31,170,12,39,39,29,140,253
DATA 253,140,252,164,140,195,225,253,253,164,164,195,164,164,160,140,157,39,30,39,30,40,39
DATA 102,144,105,101,120,120,120,120,109,76,82,75,103,17,19,20,10,23,20,19,46,62,72,77,44,42
DATA 95,145,142,101,102,12,31,39,96,1,30,39,29,128,140,253,140,140,165,157,158,142,101,16,16
DATA 152,15,138,152,6,16,138,39,39,40,39,31,30,182,121,105,107,120,120,42,125,76,64,76,72,89
DATA 119,22,20,9,8,19,97,75,247,76,76,76,60,55,92,95,101,182,96,30,30,25,96,30,39,39,41,194
DATA 101,95,29,39,49,29,39,29,39,39,39,30,39,39,39,39,29,39,39,39,30,40,12,96,96,106,145,120
DATA 120,156,60,76,76,76,84,72,103,8,23