Bitmap Manipulation in BlitzBasic.

BlitzPlus Forums/BlitzPlus Programming/Bitmap Manipulation in BlitzBasic.

Jono(Posted 2005) [#1]
Hi.

I'm wondering if it's possible to do the follow in BlitzBasic Plus:

1) Bitmap transparency ranging from 0% to 100% (Like you can do to layers in Photoshop.)
2) Bitmap rotation (Saving memory by rotating and recycle the same bitmap.)
3) Bitmap brightness ranging from 0% to 100% (Being able to make a bitmap turn brighter or darker depending on range, good for creating day and night effects over time.)

Thanks, probably need to program some kind of memory algorithm for manipulating graphics stored in memory.


jhocking(Posted 2005) [#2]
I think there was a userlib for extending the graphics funtions to do that stuff, but those sorts of manipulation aren't really possible using the built-in commands of B+. Do you already have B+? If not, take a look at BlitzMax.


Jono(Posted 2005) [#3]
I bought BlitzBasic Plus a few years ago.


sswift(Posted 2005) [#4]
Look in the Blitzplus forums for my BOB system which I released for free, minus support.


Rob Farley(Posted 2005) [#5]
Yes you can manipulate bitmaps as much as you like

Look at read and write pixel fast.

http://www.blitzbasic.com/codearcs/codearcs.php?code=551

Basically if you want to make something x% brightness you need to read the r,g and b of a pixel multiply each component by (x/100) and write the resultant rgb back.

If you want to add 2 images together, read each rgb component of each of the images, add them together and divide by 2.

It's all pretty straight forward and can be used real time (ish) for a paint package if you're using small (around 256x256) images.

Peeking and poking image buffers is faster, but I've never tried this.


Grey Alien(Posted 2005) [#6]
I've done 1) and 3) on your list very successfully with readpixelfast/writepixelfast (with LockBuffer). Make sure you only do this on managed or scratch images as it's WAY tooo slow on Dynamic images (held in VRAM). If you are going to change the alpha transparency or brightness every frame, don't use managed, just use scratch (pure RAM) as it's faster when transfering t the video buffer, trust me. If you are only going to modify it once use managed (copy in RAM and VRAM) instead. Hope this helps, I learn the hard way with loads of experimentation which way is best.

I tried getting the pixels as a bank with LockedPixels fast and peeking and poking BUT it as fag as there are at least 4 different screen modes (memory configurations) you need to support.