Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Trying to get table data from byteMap:getBytes{get_info = true}
Started by Quitalizner Jun 01 2019 01:04 AM

2 replies to this topic
bytemap getbytes pixel information

Best Answer StarCrunch , 01 June 2019 - 09:21 AM

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.)

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Quitalizner

[GLOBAL: userInfoPane.html]
Quitalizner
  • Enthusiast

  • 45 posts
  • Corona SDK

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.

 

 

 

 



[TOPIC: post.html]
#2

StarCrunch

[GLOBAL: userInfoPane.html]
StarCrunch
  • Contributor

  • 803 posts
  • Corona SDK

  Best Answer

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.)



[TOPIC: post.html]
#3

Quitalizner

[GLOBAL: userInfoPane.html]
Quitalizner
  • Enthusiast

  • 45 posts
  • Corona SDK

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. 


  • StarCrunch likes this


[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: bytemap, getbytes, pixel information