Trying to get table data from byteMap:getBytes{get_info = true}

Hello,

I wanted pixel information from image. I tried display.colorSample() but the results weren’t accurate probably because image on screen is placed according to the aspect ratio.

So I went around looking and found byteMap, since it was talked about in one of the forums.

I wanted to get a table of data returned by getBytes() method. But it prints some kinda junk value on the console.

Using this does the job per pixel. But I have to iterate over everything and then add it to the table.

local function GetAlpha (x, y) local index = (y - 1) \* w + x return alpha:byte(index) end

Using getBytes{get_info = true} didn’t do the job of returning a table. Is it broke or am i doing something wrong.

Hi Quitalizner.

The “junk value” is just the bytes, which are contained in a string.  :) The printout will probably cut short if there are 0 components in your image.

The " get_info" argument (docs in case you’re just working off the forum) just means you’ll get a second return value with some information about the final results. This was to account for clipping or format conversions, so probably not what you want.

Do you actually need a table? If you already have GetAlpha () it seems you could just use that, then nil / overwrite the closure when you want to free alpha. (You could actually rig up a proxy if you want table-style access.)

Yea, went around using just the GetAlpha() method. Totally overlooked the fact that it returns two values while I was going through the documentation.

I got around learning meta tables and meta methods. So proxy seems like a good thing to know about.

Thanks StarCrunch, it’s like I learn something new on this forum every time and I love it. 

Hi Quitalizner.

The “junk value” is just the bytes, which are contained in a string.  :) The printout will probably cut short if there are 0 components in your image.

The " get_info" argument (docs in case you’re just working off the forum) just means you’ll get a second return value with some information about the final results. This was to account for clipping or format conversions, so probably not what you want.

Do you actually need a table? If you already have GetAlpha () it seems you could just use that, then nil / overwrite the closure when you want to free alpha. (You could actually rig up a proxy if you want table-style access.)

Yea, went around using just the GetAlpha() method. Totally overlooked the fact that it returns two values while I was going through the documentation.

I got around learning meta tables and meta methods. So proxy seems like a good thing to know about.

Thanks StarCrunch, it’s like I learn something new on this forum every time and I love it.