Link to home
Start Free TrialLog in
Avatar of csmikeb
csmikeb

asked on

Fast access to bitmap data

I need to grab the colour data from a bitmap, manipulate it then write it back to the bitmap.  This needs to compile in D1.0 (without Win32.API) but needs to run reliably under W3.1 and W95.  I really need to treat the data I get from the bitmap as 24BBP information, even if the bitmap was actually palettised.  Pixels property and WinAPI GetPixels are WAY TOO SLOW.  Speed is of the essence!
Avatar of ywoedta
ywoedta

The two functions (API) that you need are GetBitmapBits and SetBitmapBits.  Both use an array of pixel information, which you can then write your own access routines for (seeing as how you are so concerned with speed, that's the only way to make sure.)
Hope this is what you were looking for.
Avatar of csmikeb

ASKER

I am aware of the Get and Set bitmap bits API functions, but there is also a getDIB and setDIB function, what I really need to know is not what functions are there, (this much I already know) but how those functions should correctly and portably be used so that they work with at least the vast majority of graphics cards.
What is the file, bmp, dif, etc?
Avatar of csmikeb

ASKER

Errr, not sure that it makes any difference does it?  I'm not working on the raw data of the file, (in fact currently they are a mixture of different file types, GIF, JPG and BMP, loaded through the medium of the Image Lib TPMulitImage component. But surely that makes no difference?  By the time I am at the stage of wanting to edit, the image is held in an internal bitmap format, whatever the source type WAS.  All I want is to have rapid access to the data...  This was all SOOOOOOooo easy under Unix....
If you are programming in Delphi, TBitmap is the best way to edit and display etc files in memory.  It handles all of the features needed and even has a TCanvas so you can draw on the bitmap.  Also it will display the image in any windows form etc with just one call.  You can access individual pixels and such.  I'm not sure how many colors it will handle (the built in object that is) but it can be redefined to handle more with a new object.  You will have to handle all conversion of files into the Bitmap format but once that is done, the access will be quite fast.  Additionally, there are routines that are out there to do the conversion for you.  

If you are more familiar with C++ also, you can use C++ Builder instead of Delphi.  With Unix as your background, you will probably feel more confortable with C++ Builder.  It has the TBitmap also built in.
Unfortunately, C++ Builder will not satisfy your condition of No WIN32.  Sorry about that.
ASKER CERTIFIED SOLUTION
Avatar of mirek071497
mirek071497

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of csmikeb

ASKER

Thanks Mirek, this has the potential to do what I want it to, although it will need adapting for different colour resolutions I think...