One Star Review : GetPixel() needed and soon!

Ok, maybe start here:
http://falcon80.com/HTMLCanvas/PixelManipulation/getImageData.html

Trouble is bridge between lua and javascript but you can create file in lua with image name and open it in javascript, get your job done, save result in text file and read it in lua.

Look at Code Sample -> CoronaSDK/SampleCode/Interface/WebOverlay

It’s looks crazy but it’s only way right now I think…

Best regards [import]uid: 12704 topic_id: 24518 reply_id: 108965[/import]

jeff472, did you get something working in the end? I’ve been testing corona for suitability but pixel manipulation or even just reading RGB values is important to what we want to do.

I’m going to take a look at gtatarkin’s suggestion. [import]uid: 155699 topic_id: 24518 reply_id: 117115[/import]

Ive got nowhere with the hints above.
Several more 1 star reviews later, its killing my sales, and I now have competition who CAN do this. :(((

All I can do is apologise to people on Facebook page, and watch the bad reviews come in.
I’ve never been so powerless when coding an app: normally I just ‘find another way’ and move on, but there really doesnt seem to be one here.

At the moment I have a framework started in XCode: its much harder to use, and it pains me to have to waste another year starting from scratch.
All for the sake of exposing one function which already exists!

When (if?) Enterprise appears, maybe someone will be able to add this in some way?

If you can get any success from uploading an image to somewhere, then using a java script to access HTML5 to get a value, I’ll be very happy to hear from you and willing to pay for usable code. [import]uid: 108660 topic_id: 24518 reply_id: 117127[/import]

Working example in javascript and canvas

[javascript]
function imageLoaded(ev) {
element = document.getElementById(“cancan”);
c = element.getContext(“2d”);

im = ev.target; // the image, assumed to be 200x200

// read the width and height of the canvas
width = element.width;
height = element.height;

// stamp the image on the left of the canvas:
c.drawImage(im, 0, 0);

// get all canvas pixel data
imageData = c.getImageData(0, 0, width, height);

w2 = width / 2;

// run through the image, increasing blue, but filtering
// down red and green:

for (y = 0; y < height; y++) {
inpos = y * width * 4; // *4 for 4 ints per pixel
outpos = inpos + w2 * 4
for (x = 0; x < w2; x++) {
r = imageData.data[inpos++] / 3; // less red
g = imageData.data[inpos++] / 3; // less green
b = imageData.data[inpos++] * 5; // MORE BLUE
a = imageData.data[inpos++]; // same alpha

b = Math.min(255, b); // clamp to [0…255]

imageData.data[outpos++] = r;
imageData.data[outpos++] = g;
imageData.data[outpos++] = b;
imageData.data[outpos++] = a;
}
}

// put pixel data on canvas
c.putImageData(imageData, 0, 0);
}

im = new Image();
im.onload = imageLoaded;
im.src = “200px.jpg”; // code assumes this image is 200x200
[/javascript]

What exact functionality do you need? Will check if it’s possible and what about preformance. [import]uid: 12704 topic_id: 24518 reply_id: 117132[/import]

That looks promising, and thank you for spending that time.
It looks as if I may be better off doing the image processing entirely in java, and then returning a list of values as a web page which I can download back to my app?
(This does seem to imply internet access…)

My basic requirement is to ‘know’ the RGB values of every pixel of a picture.
Secondary to that is to quantise the data into no more than (n) colors
Then to force map onto a predefined palette.

I want to do that in the LUA code structure. But if I do it all ‘out of process’, and get a list of results, that will do.

Others who need this functionality may only need step 1: using a bitmap as a games map.
Still others might want to use the ‘amend the values’ functionality to change the bitmap and/or create on the fly pictures (but we can do that now using a picture made up of many imagerects)
You are right to ask about performance, but my answer is this:
If you were washed out to sea, would you rather be able to swim at 1 km per hour, or not be able to swim at all?
[import]uid: 108660 topic_id: 24518 reply_id: 117133[/import]

Extracting image data using JavaScript is possible but the problem is what do you do with the data since JavaScript will not allow you to save the data to a file and there is no way to extract it from the web view.

Even if you could save the image data, there is an issue of size. A 200x200 pixel image would require 160,000 bytes of binary data. This value would be multiplied when saved as ASCII text or Lua floating point numbers. Going to larger images makes this problem worst and in some cases would exceed the memory allocation used to transport the data (not to mention the time to render, convert, and pack the data).

So it comes down to how the data will be used. If would be practical if your needs are to extract a few pixels from an image. If you want to capture the entire image or need to modify the image and save the image, that is not going to work with JavaScript. I would guess that most users who want to have access to individual pixels want to read and write the entire image and not just read a few pixels.

We have looked at providing the OpenGL APIs (read/write pixel) for doing this but this would be it would also be slow to access and hack with our current implement. Even if we tell users it would be slow, we would still get complaints about it and demand that it be fixed.

-Tom [import]uid: 7559 topic_id: 24518 reply_id: 117318[/import]

>> it would also be slow to access and hack with our current implement.Even if we tell users it would be slow, we would still get complaints<<

Probably.
And yet right now, both you and I are getting complaints that it’s impossible.
I’d rather arrive late than never.

I get it. I really do. Damned if you do, and damned if you don’t.

But right now, we can only take your word about speed, and its all relative, surely. Maybe its fast *enough*
If you are prepared to ignore complaints about the absence, why not ignore complaints about the speed instead?
You lose nothing, and some of us gain a feature. [import]uid: 108660 topic_id: 24518 reply_id: 117321[/import]

Jeff,

I do understand your frustration but you have to realize that we have limited resources and we are our trying our best to fix bugs and add features. The Mt. Lion/Xcode 4.4 upgrade took more time than we planned (it always does) and we are trying to add features to Android to get feature parity with iOS.

When we looked at adding the get/setPixel API, our in-house iOS expert pointed out a number of issues and when you balance adding a feature that is sure to generate complaints with adding something that many users are asking for, that guides what we will work on. We could take take the time and try to implement a Pixel API but if we get complaints and it’s only useful to a few, our time would be better spent on something else.

We are looking to rework our OpenGL implementation in the future and the ability to operate at the pixel level (or equivalent) is planned.

With that said, does your application only need to read the image pixels or does it also need to change pixels and save the image too? (I was looking at our code and trying to determine if there is something simple (but maybe slow) that could be implement.)

-Tom [import]uid: 7559 topic_id: 24518 reply_id: 117351[/import]

Thank you for replying, Tom.
>I do understand your frustration but you have to realize that we have limited resources<

Of course. I do understand.

>When we looked at adding the get/setPixel API>.<
In a way, its a shame that it wasn’t added at that point, but simply not documented.
That way, a small bunch of people could have tried it and offered another opinion.

>does your application only need to read the image pixels<
I realise I have made a bit of a noise here, but its because its such a fundamental need for me.
I’m sorry, because I know what its like at your end faced with that.
For my specific needs, I literally only need to be able to know the red, green,blue values for an x,y co-ordinate.
That could be from the current screen, or from an in-memory image, or an image on disc: I could find a way through any of those routes.
Others asking for this ability want to do the same to be able to use a picture as a games map.

Personally, Im not wanting to change the values or create an image by drawing at the pixel level (I can do that already using imagerect if I want to)
[import]uid: 108660 topic_id: 24518 reply_id: 117358[/import]

@jeff472, I am not sure if I am just talking nonsense here, but would you be able to address your issue using native code? If so, maybe its worth you looking at the Enterprise subscription, I recall reading that Corona are planning an Indie friendly pricing model. Worth a look. [import]uid: 144378 topic_id: 24518 reply_id: 117440[/import]

M-Game Minion, it looks like Jeff is starting to look native based on his Xcode comments. At least I’ve not committed a lot of time to the project I wanted to do in Corona, unlike Jeff. It would be good if there was indie friendly pricing for enterprise subscriptions.

getPixel seems like such a innocent request, too bad the feature is deemed too slow (not overly relevant for myself, or Jeff, by the sounds of it). Hoping for the enterprise sub to work around this.

Thanks for the comments Jeff/Tom.

Jacko [import]uid: 155699 topic_id: 24518 reply_id: 117467[/import]

According to the ‘Roadmap’ (http://www.coronalabs.com/resources/roadmap/), is anything under the ‘Graphics 2.0’ going to implement any getPixel(x,y) functionality?

Cheers in advance, [import]uid: 21125 topic_id: 24518 reply_id: 143160[/import]

According to the ‘Roadmap’ (http://www.coronalabs.com/resources/roadmap/), is anything under the ‘Graphics 2.0’ going to implement any getPixel(x,y) functionality?

Cheers in advance, [import]uid: 21125 topic_id: 24518 reply_id: 143160[/import]

According to the ‘Roadmap’ (http://www.coronalabs.com/resources/roadmap/), is anything under the ‘Graphics 2.0’ going to implement any getPixel(x,y) functionality?

Cheers in advance, [import]uid: 21125 topic_id: 24518 reply_id: 143160[/import]

According to the ‘Roadmap’ (http://www.coronalabs.com/resources/roadmap/), is anything under the ‘Graphics 2.0’ going to implement any getPixel(x,y) functionality?

Cheers in advance, [import]uid: 21125 topic_id: 24518 reply_id: 143160[/import]