hi
My question is it possible to draw picture based on array?I attached photo in Matlab and I got table with values of every pixels(for example 1 254
1 1
1 1
252 254)
and now i want to draw it on Corona. Could anyone help me ? Any ideas? I attached files with image and Excel’s file. My main target is to make coloring book fool filling image.
thanks for help, I m just learning 
Hey patrikes,
so you’ve got an array which contains color values for each pixel in your image and now you want to draw that image?
Don’t know if Corona is made for such thing (especially for images with 1.000.000+ pixels), but you could try using a canvas and draw the image pixel bei pixel with rects.
https://docs.coronalabs.com/api/type/SnapshotObject/canvas.html
https://docs.coronalabs.com/api/library/display/newRect.html
Best regards,
Torben
@torbenratzlaff yes i want to do that, could you help me maybe with any alghoritms? Should I load array to table and then use algorithm to impute them to variables, I have problem how to do that algorithm. Thx for reply.
Well, it depends on the array you’ve got. If you store RGB values for each pixel, something like this could work:
local colorArray = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {1,1,1}, {1,1,1}, {1,1,1}, {1,1,1}, {1,1,1}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, } local imageWidth = 5 local imageHeight = 5 for i=1, imageWidth\*imageHeight do local pixelColor = colorArray[i] local pixel = display.newRect(0, 0, 1, 1) pixel:setFillColor(pixelColor[1], pixelColor[2], pixelColor[3]) pixel.x = (i-1)%imageWidth pixel.y = math.floor(i/imageWidth) end
Of course you would have to add the pixels to the canvas. But about that you should read some guides about snapshots and canvases in Corona.
This is just a starting point. Corona is not the optimal framework to do such things (even if they are possible).
Hey patrikes,
so you’ve got an array which contains color values for each pixel in your image and now you want to draw that image?
Don’t know if Corona is made for such thing (especially for images with 1.000.000+ pixels), but you could try using a canvas and draw the image pixel bei pixel with rects.
https://docs.coronalabs.com/api/type/SnapshotObject/canvas.html
https://docs.coronalabs.com/api/library/display/newRect.html
Best regards,
Torben
@torbenratzlaff yes i want to do that, could you help me maybe with any alghoritms? Should I load array to table and then use algorithm to impute them to variables, I have problem how to do that algorithm. Thx for reply.
Well, it depends on the array you’ve got. If you store RGB values for each pixel, something like this could work:
local colorArray = { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {1,1,1}, {1,1,1}, {1,1,1}, {1,1,1}, {1,1,1}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, } local imageWidth = 5 local imageHeight = 5 for i=1, imageWidth\*imageHeight do local pixelColor = colorArray[i] local pixel = display.newRect(0, 0, 1, 1) pixel:setFillColor(pixelColor[1], pixelColor[2], pixelColor[3]) pixel.x = (i-1)%imageWidth pixel.y = math.floor(i/imageWidth) end
Of course you would have to add the pixels to the canvas. But about that you should read some guides about snapshots and canvases in Corona.
This is just a starting point. Corona is not the optimal framework to do such things (even if they are possible).