Possible to the color of specific pixels in bitmaps?

Hey Corona-ites,

Trying to figure out how to code up a coloring book where you could fill an area with color.  I see a recent update has added display.colorSample to tell what color a specific pixel is, which is helpful, but I also need something that would let me change the color of that pixel.  Does this function exist?  It looks like it was requested in Feature Request here: http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3574788-bitmap-manipulation and split into 3 requests (all of which look to be marked as completed), but I can’t find anything regarding changing a pixel’s color.

Thanks for your help!

Maybe they didn’t add it in the docs? Well we might have to wait for @Brent as he seems to be the docs guy around here.

–SonicX278 

Hey batgirl,

all 3 requests under the link you’ve posted have been implemented.

  1. Bitmap manipulation – Read pixel (e.g. for selecting a color)

You wrote about this one yourself.

  1. Bitmap manipulation – Filter effects on images (e.g. color transform, contrast, etc)

Many many filters have been added and you may write your own.

https://docs.coronalabs.com/api/type/Paint/effect.html

  1. Bitmap manipulation – Render display object to a texture

This is possible with snapshots and canvases.

https://docs.coronalabs.com/guide/graphics/snapshot.html

Hope you find what you are looking for :slight_smile:

Thanks guys for your help!

Torbenratzlaff:

Yeah, they all have been, but none of them are quite what I want! :slight_smile:  The OP for the first request that got split up mentioned using it for coloring books, but this specific feature I can’t seem to find.  It’s not listed in the 3 items split up.

  1. Reading pixel color- helpful but I need writing pixel color too

  2. Filters- not really what i’m looking for. i need something to just change part of an image, not the whole image itself.

For example, on this beautifully drawn coloring page, i’d want to be able to touch the cat head, read that it’s white, then turn that pixel and every adjacent white pixel into a different color.  Recoloring the entire image wouldn’t work.
cat-head2.png

  1. Also helpful but not quite what I’m looking for.  This appears to just save the objects on the screen to a file.  I’ve used this for other projects but it’s not quite what I need.

Thanks for taking the time to reply.  If you know of any way to change the pixel color, I’d really appreciate it! :slight_smile:

Hey batgirl,

thanks for clearification, now I understand your problem better.

Currently there is no way to recolor specific pixels of an image as far as I know.

I’ve got an idea in mind that I want to share with you, but I don’t know if this works.

Let’s say you want to paint a certain area. You use a snapshot to create a single image from several strokes.

Now you take your original image (the cute kitten) and use that as a fill on the snapshot. After that you add another fill, which could be any kind of filter. After that you need to merge all the different images into a single one.

Does this make any sense to you?

You are looking for a technique called “Flood Fill” where you can fill all the pixels with a color until you hit a boundary color that stops the fill.  There are two problems with this in the Corona world.  First it’s prone to errors. If the person drawing your cat doesn’t completely close the black border, your paint color will leak out and fill the outside too. Secondly, we don’t support settings pixels.

Rob

Thanks for your help Rob!  Hmm, I knew about the closed-area thing, but I was afraid there just wouldn’t be the setting in Corona.  I’m going to add it to the feature request- any particular way I should phrase it/keywords I should use so it’s clear?

Thanks Torbin - it sounds like an interesting method, although I’m looking for something as low-key as possible, ideally this thing that turns out is impossible XD  Appreciate the help tho!

I would title it:  Bitmap manipulation - Set pixel color (e.g. for filling a portion of the image with color)

Then for the description: I would like to arbitrarily fill an area of an  image using a technique like flood fill. I need to be able to set the pixel color as well as get the pixel color to determine if I should change it.

Go to http://feedback.coronalabs.com and create this.

Thanks

Rob

Thanks Rob!  Just posted it up:

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/13052361-bitmap-manipulation-set-pixel-color-e-g-for-fi

if anyone else ends up at this thread, please vote for this feature!  It would make coloring book apps much easier to create!

Thanks again :slight_smile:

Hi BatGirl,

I also need the same thing and talked with Rob.https://forums.coronalabs.com/topic/62717-paint-bucket-functionality-with-corona/?hl=paint
Corona still has nothing in it. :frowning:

I am voting this up.

Also if you find any success in it. Please share it up here.

Thanks

Maybe they didn’t add it in the docs? Well we might have to wait for @Brent as he seems to be the docs guy around here.

–SonicX278 

Hey batgirl,

all 3 requests under the link you’ve posted have been implemented.

  1. Bitmap manipulation – Read pixel (e.g. for selecting a color)

You wrote about this one yourself.

  1. Bitmap manipulation – Filter effects on images (e.g. color transform, contrast, etc)

Many many filters have been added and you may write your own.

https://docs.coronalabs.com/api/type/Paint/effect.html

  1. Bitmap manipulation – Render display object to a texture

This is possible with snapshots and canvases.

https://docs.coronalabs.com/guide/graphics/snapshot.html

Hope you find what you are looking for :slight_smile:

Thanks guys for your help!

Torbenratzlaff:

Yeah, they all have been, but none of them are quite what I want! :slight_smile:  The OP for the first request that got split up mentioned using it for coloring books, but this specific feature I can’t seem to find.  It’s not listed in the 3 items split up.

  1. Reading pixel color- helpful but I need writing pixel color too

  2. Filters- not really what i’m looking for. i need something to just change part of an image, not the whole image itself.

For example, on this beautifully drawn coloring page, i’d want to be able to touch the cat head, read that it’s white, then turn that pixel and every adjacent white pixel into a different color.  Recoloring the entire image wouldn’t work.
cat-head2.png

  1. Also helpful but not quite what I’m looking for.  This appears to just save the objects on the screen to a file.  I’ve used this for other projects but it’s not quite what I need.

Thanks for taking the time to reply.  If you know of any way to change the pixel color, I’d really appreciate it! :slight_smile:

Hey batgirl,

thanks for clearification, now I understand your problem better.

Currently there is no way to recolor specific pixels of an image as far as I know.

I’ve got an idea in mind that I want to share with you, but I don’t know if this works.

Let’s say you want to paint a certain area. You use a snapshot to create a single image from several strokes.

Now you take your original image (the cute kitten) and use that as a fill on the snapshot. After that you add another fill, which could be any kind of filter. After that you need to merge all the different images into a single one.

Does this make any sense to you?

You are looking for a technique called “Flood Fill” where you can fill all the pixels with a color until you hit a boundary color that stops the fill.  There are two problems with this in the Corona world.  First it’s prone to errors. If the person drawing your cat doesn’t completely close the black border, your paint color will leak out and fill the outside too. Secondly, we don’t support settings pixels.

Rob

Thanks for your help Rob!  Hmm, I knew about the closed-area thing, but I was afraid there just wouldn’t be the setting in Corona.  I’m going to add it to the feature request- any particular way I should phrase it/keywords I should use so it’s clear?

Thanks Torbin - it sounds like an interesting method, although I’m looking for something as low-key as possible, ideally this thing that turns out is impossible XD  Appreciate the help tho!

I would title it:  Bitmap manipulation - Set pixel color (e.g. for filling a portion of the image with color)

Then for the description: I would like to arbitrarily fill an area of an  image using a technique like flood fill. I need to be able to set the pixel color as well as get the pixel color to determine if I should change it.

Go to http://feedback.coronalabs.com and create this.

Thanks

Rob

Thanks Rob!  Just posted it up:

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/13052361-bitmap-manipulation-set-pixel-color-e-g-for-fi

if anyone else ends up at this thread, please vote for this feature!  It would make coloring book apps much easier to create!

Thanks again :slight_smile:

Hi BatGirl,

I also need the same thing and talked with Rob.https://forums.coronalabs.com/topic/62717-paint-bucket-functionality-with-corona/?hl=paint
Corona still has nothing in it. :frowning:

I am voting this up.

Also if you find any success in it. Please share it up here.

Thanks

In case you’ve not seen it, you might take a look at the memory bitmap plugin that recently went live.

It definitely deserves more attention. Maybe I’ll make and post some examples later.

In connection with memory bitmaps, the plugin(s) I mention in this thread might also prove useful, once ready.