Page 1 of 1

How to draw2DImage without a specific pixel?

Posted: Tue Jan 29, 2008 6:45 pm
by MasterGod
How to draw2DImage without a specific pixel?
E.g I have a 16x16 image and I want to draw it without the pixel at 8x8, how can I accomplish that?

Thanks.

Posted: Tue Jan 29, 2008 7:22 pm
by Frosty Topaz
Only thing I can think of is to manually edit the image and remove the pixel.

Posted: Tue Jan 29, 2008 10:15 pm
by Dark_Kilauea
by edit, you can always use the lock() and unlock() interface to edit the texture in real time.

Posted: Wed Jan 30, 2008 9:01 am
by JP
Yeah there's no other way to do it really... Technically you could do it by drawing it onto something more complicated than a simple 2 poly quad and have a 1 pixel gap in the quad where you don't want anything drawn but that would be a bit too complicated for your needs and i suspect you might want to not draw any number of pixels instead of just the one at 8x8?

So i reckon you'd have to edit the texture with lock() and unlock(). Maybe you'd want to make a completely new copy of the texture so that you have the original, unedited texture to fall back on, depending on your needs.

Posted: Wed Jan 30, 2008 6:54 pm
by keless
bitmask, anyone?

Posted: Wed Jan 30, 2008 7:32 pm
by JP
Fair point... :lol:

Posted: Wed Jan 30, 2008 7:50 pm
by Acki
you can also define a transparent color and set the pixle at 7,7 (for pixle 8,8 ) to this color (with lock/unlock)...

Posted: Wed Jan 30, 2008 8:35 pm
by MasterGod
May I have a code snippet for such thing? I never worked with lock/unlock so I don't know how to use it.

Posted: Wed Jan 30, 2008 9:23 pm
by Acki
something like this:

Code: Select all

SColor* colMap = (SColor*)theImage->lock();
// assuming the texture is 16x16 and you want pixle at 7,7
colMap[16 * 7 + 7] = SColor(add transparent color here);
theImage->unlock();
this is a simple example, but you can play around with it... ;)