Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Creating an empty image using ofImage::allocate

$
0
0

@cuinjune wrote:

Hi, I'm trying to create an empty image so I can edit its pixels later.

void ofApp::setup(){

    img.allocate(100, 100, OF_IMAGE_COLOR);

    for (size_t i=0; i<img.getPixels().size(); ++i)
        img.setColor(i, ofColor(255,0,0));

    cout << img.getPixels().size() << endl;

    img.update();
}

I tried this code but it just draws white image.
Why doesn't it draw red image? how do I properly color pixels?
And I don't understand why img.getPixels().size() returns 30000 and not 10000.
Please help.

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles