ofImage.draw(x, y) draws a black box instead of the actual image

I want to draw an image in my flocking program, but something goes wrong…
The image is loaded without any error,so I assume something goes wrong within my code.

ofImage beehouse;
beeHive.loadImage("house.png");
beeHive.allocate (50,50, OF_IMAGE_COLOR);
beehouse.draw(350, 350);

Url to the image, since i can’t post images as a new user

you call allocate after you load the image, so you are basically “resetting” the memory – allocate should only be called when you want to create an image without loading anything.

additionally, you should consider where you load the image – if this code is inside of draw, you are loading the image every draw call. Typically the best approach is to define your variable in the .h file:

ofImage beehouse;

load your image in setup

beeHive.loadImage("house.png");

and draw your image in draw:

beehouse.draw(350, 350);

Also check out \examples\graphics\imageLoaderExample in the OF download.

It gives a runnable example of the approach described by zach.

Thanks Zach, that seemed to be the program. You are right about putting loadImage in the setup which I indeed have. I just posted all the code I thought was relevant for this question.