我一直试图将图像实现到我在lua中制作的程序窗口中我基本上做的是获取图像的所有RGB信息并将其绘制在画布上,因为所有脚本都在线存储并使用LuaSocket
进行调用增加我的服务器的虚拟使用量,所以我试图将图像RGB数据保存到文本文件并加载它,并在画布上制作图像,但无法做到这一点,它只是在这里创建一个没有RGB信息的空白图像就是我在做什么
这是我图像的rgb表的小部分(示例)
Flower = {}
Flower[1] = {}
Flower[1][1] = 16446446
Flower[1][2] = 3552822
Flower[1][3] = 3552822
Flower[1][4] = 3552822
Flower[1][5] = 3552822
Flower[1][6] = 3552822
Flower[1][7] = 3552822
Flower[1][8] = 3552822
Flower[1][9] = 3552822
Flower[1][10] = 3552822
Flower[1][11] = 3552822
Flower[1][12] = 3552822
Flower[1][13] = 3552822
Flower[1][14] = 3552822
Flower[1][15] = 3552822
Flower[1][16] = 3552822
Flower[1][17] = 3552822
Flower[1][18] = 3552822
Flower[1][19] = 3552822
Flower[1][20] = 3552822
Flower[1][21] = 3552822
Flower[1][22] = 3552822
Flower[1][23] = 3552822
Flower[1][24] = 3552822
它真的很大,结束于
Flower[448][235] = 16446446
所以我在我的程序中做的是
local f = assert(io.open(MyPath.."log.txt", "r"))
content = f:read("*all")
f:close()
return content
Form = createForm(true)
Form.width = 447
Form.height = 234
image = createImage(Form);
image_stretch(image, true);
image.width = 447
image.height = 234
image.top = -10
image.left = -10
setProperty(image, 'Anchors','akTop,akLeft,akRight,akBottom');
canvas = image.getCanvas();
brush = canvas.getBrush();
brush.Color = 0xF0F0F0;
canvas.fillRect(canvas, 0, 0, Form.width, Form.width);
pen = canvas.getPen();
pen.width = 2;
pen.Color = 0x000000;
for i,table in pairs(Flower) do
for _,color in pairs(Flower[i]) do
canvas_setPixel(canvas, i + 5 , _ + 5, color)
end
end
答案 0 :(得分:0)
我已经对它进行了排序并获得了答案而不是使用io.open
打开文件我使用dofile
所以而不是
local f = assert(io.open(MyPath.."log.txt", "r"))
content = f:read("*all")
f:close()
return content
做了
dofile(MyPath.."log.txt", "r")
它完美无缺