Note that there are some explanatory texts on larger screens.

plurals
  1. POErase parts of image to make pixels transparent
    primarykey
    data
    text
    <p>I'm working in <em>openFrameworks</em>, a set of C++ libraries.</p> <p>What I'm trying to do is simply 'erase' certain pixels of an ofImage (a class that loads/displays an image, and has access to it's pixel array) when a shape (an eraser) passes over the appropriate pixels of the image. Pretty simple stuff - I think - but I'm having a mental block!</p> <p>ofImage has two methods - <code>getPixels()</code> and <code>getPixelsRef()</code> that seem to approach what I am trying to do, but the methodology I am using is not quite giving me the results I want.</p> <p>Here is an example of an attempt to update the pixels of a foreground image from the pixels of a background image:</p> <pre><code>ofPixelsRef fore = foreground.getPixelsRef(); ofPixelsRef back = background.getPixelsRef(); for(int x = 0; x &lt; foreground.getWidth()/2; x++) { for (int y = 0; y &lt; foreground.getHeight(); y++) { ofColor c = back.getColor(x, y); fore.setColor(x, y, c); } } </code></pre> <p>foreground.setFromPixels(fore);</p> <p>and here is an attempt to statically colour the foreground with a predetermined colour (which I think is what I want to do, with a transparent white ?!?):</p> <pre><code>ofPixelsRef fore = foreground.getPixelsRef(); ofColor c(0, 127); for(int x = 0; x &lt; foreground.getWidth(); x++) { for (int y = 0; y &lt; foreground.getHeight(); y++) { fore.setColor(x, y, c); } } foreground.setFromPixels(fore); </code></pre> <p>Neither are quite where I want to get to, but I think they're a stab in the right direction. If anyone has any ideas on where to proceed, I'm all ears. </p> <p>I'd consider moving to the ofFbo class, or even GLSL if there's a clean lead/example. Feel free to post vanilla C++ as well, and I'll see what I can do about porting it to oF.</p> <p>Thanks, </p> <p>~ Jesse</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload