getPixel() again & again

In theory yes, if implemented better :slight_smile:

Adobes ColorMatrixFilter is a pig and that is being nice lol…

But same logic applies yes.

like i said a nice to have, but at the moment i am just happy being able to apply fillcolors on masks :) 

a pig? in terms of performance? or in terms of usage? what would make it better?

Performance mostly but that could have been just flash as I am not a big fan :slight_smile:

personally I think something as simple as the fill color option would be nice just add find color replace color and it would be super simple to use so long as it didn’t hammer the texture memory.

But man would it be nice for sprites lol

One thing of note - changing the pixel colour is not the same as tinting an image.

In the example image posted above you aren’t going to have much success converting all black of the t-shirt to another colour as it isn’t going to handle anti-aliasing at all (except where it is only a result of alpha channel, but that itself implies overlaying various images).

Laying the images one over the other would be the best way for this, or possibly even using polygon shapes.

If you need to use the ‘final’ image a lot, you might be able combine it all into a snapshot and work with that, depending on the specifics of the case.

The way I do it is pretty simple and provides the best output at the moment and since everything is in an image sheet I just really keep and index like shirt=1 etc and color index = 3 and what not.

It would just be nice to have white on something and have it not effected by fill color etc. lol

Actually come to think about it, if there was an option to exclude solid white on set fill color I would be ecstatic :slight_smile:

If you don’t want to change white and black, the hue filter might do what you want.  

Thanks Rob, I will give it a try and see what happens, just now getting into the 2.0 effects etc. so haven’t really pushed it to see what I could do as I just got done with the port up to 2.0 for this particular project but thinking about it now the hue filter would be PERFECT for eyeballs lol…

Here is a visual breakdown with pseudo-code that might help illustrate the two different features.  I’m using a hex color just as an example.

The “get” color:

11c9m41.png

The “set” color:

2f0bw4y.png

It’s not a tint as noted earlier, nor a regular fill, it’s a find and replace.

With this functionality I can easily replace or add color choices without creating a new avatar image for each one.  I can also use one base icon for possibly limitless combinations.

Hope that helps.

@Rob, I just had some time to play around with using a hue filter and unlike Photoshop and other paint programs etc. the hue filter in 2.0 hues white as well so hueing something orange causes the white areas to go light peach color where if i were to change the hue on the same thing in photoshop it only changes anything that is off white etc.

+1, was thinking of using a feature like this to dynamically be able to set the color of the statusbar

I would use the getPixel() and setPixel() in ActionScript to create custom avatars very easily.  Would love to have that feature again. 

Please use the feedback site to vote this up:

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3625203-bitmap-manipulation-read-pixel-e-g-for-selecti

Done.  Thanks Rob.

Can you guys give me more context into your use case?

The reason I ask is b/c with a GPU pipeline, you have to do things differently than you might in a pure CPU pipeline (e.g. Flash). So in a modern GPU pipeline, you do almost all pixel manipulation in a shader. 

Classically, i.e. CPU-based renderers, you could just manipulate bitmaps, read or write, and then just flush those changes to the framebuffer. Or you could just read the framebuffer directly. With GPUs, those operations are very costly, but that loss of control was outweighed by the benefits.

So depending on what you want to do, there’s probably a GPU-way of doing it, but I need to understand what you want to do.

For example:

* a color picker use case (i.e. sample an individual color from the screen) could probably be done via some async mechanism. It’s not going to be in real-time, so just be aware of that. We’d have to implement that, but it’s not clear who wants this.

* another use case would be that you relax the real-time constraint. In particular, you are okay with manipulating the image *offscreen* and then when you’re done, handing the image to Corona. In this case, you would want to do this in native C code for performance reasons, as Lua would probably be too slow to manipulate images on a per-pixel basis.

* yet another would be that you want to draw into your own texture and use that to fill other objects. This is on the roadmap, and what you would ultimately use here are snapshot objects.

* or maybe you want to do a canvas style effect where you can “draw” onto a texture. Snapshot objects have the ability to let you do this: https://blog.coronalabs.com/blog/2013/11/01/snapshot-canvas-paint-brushes-trailing-object-effects-etc/

* Etc

* Etc

* Etc

My point is there are a lot of use cases and they may require new techniques, ones that are appropriate to Corona’s GPU pipeline.

For example, there were some Mode7-like techniques, and on a SNES you’d do it one way to achieve the effect, but in Corona, you’d use snapshot objects: http://forums.coronalabs.com/topic/40443-mode-7-demo-full-source/

So if you can give me use cases, we can make sure we’re targeting them as we continue to push G2.0 forward!

Hi Walter,

In my case, it would not need to be real-time.  In AS3 you can get the color under the mouse pointer, as well as replace a color in a bitmap.

So, it seems like it’s 2 different needs.  One would be the ability to find and replace a color on a bitmap.  The other would be the ability to get the color value from a finger tap.  But, the more I think about it, it’s probably going to be difficult to do something like that since the precision of a mouse pointer is lost on a touch device.  Of course if it was a large enough area of color, it could still be useful.

Hope that helps.

@develephant, can u give me an idea of the visual effect you want to achieve?

Yes.

Let’s say I have a simple 2D avatar, mostly solid colors for skin, shirt, pants, etc. and I want the user to be able to adjust some of the colors to add some variation, especially in a multi-player setting.

Instead of having to create the multitude of avatar options, I could present a panel with some color options.  Once a color was tapped on the color panel ( getPixel() ) then I could apply that to the chosen piece for the avatar – pants for example – which would require a color “find and replace” ( setPixel() ) and let’s assume the starting pants color is a value I know in advance.  I could then replace that color with the user selected color, save that out, and have the users avatar.

It could also be used in a variety of other cases, but that’s a simple one.

So I suppose it would look something like:

local colorTbl = getColorAt( x, y ) replaceColor( colorToFind, colorToReplace )   

Thanks for adressing this Walter. In my case I would use the feature similar to Develephant, to get the color of a specific pixel on the screen, ie. ‘getPixelColorAt(x, y)’ and then use the color returned to fill a newRect that is placed behind the statusbar with. This way I could check whether the toolbar in a certain scene contains ‘x’ color, i could fill the statusbar with a matching color dynamically without having to know what the colors will be before hand.