Board index » delphi » TBipmap won't load .bmp saved with photoshop

TBipmap won't load .bmp saved with photoshop


2004-06-17 04:25:16 AM
delphi175
Hi,
I have a problem with the TBitmap. It appears it won't load .bmp files that
are created using Photoshop (notmap RGB photo). PaintShop will read it as
will Windows Paint. Still I get a Stream Read Error when trying to load the
bmp in a TBitmap.
Does anyone recognize this?
Btw. I use Delphi 7
Thank s in advance
Hert
 
 

Re:TBipmap won't load .bmp saved with photoshop

ps bmp files created with other applications can be loaded without problems.
 

Re:TBipmap won't load .bmp saved with photoshop

Yes, this issue appears when your BMP file size is multiple of 16..
I don't know how to fix this in delphi. But you can load the bmp in windows paint and save again, then delphi is able to read the
bmp..
--
Samson Fu
"Hertwig" <XXXX@XXXXX.COM>writes news:40d0acfc$XXXX@XXXXX.COM...
Quote
Hi,

I have a problem with the TBitmap. It appears it won't load .bmp files that
are created using Photoshop (notmap RGB photo). PaintShop will read it as
will Windows Paint. Still I get a Stream Read Error when trying to load the
bmp in a TBitmap.

Does anyone recognize this?

Btw. I use Delphi 7

Thank s in advance

Hert


 

Re:TBipmap won't load .bmp saved with photoshop

On Wed, 16 Jun 2004 22:25:16 +0200, "Hertwig" <XXXX@XXXXX.COM>
writes:
Quote
I have a problem with the TBitmap. It appears it won't load .bmp files that
are created using Photoshop (notmap RGB photo). PaintShop will read it as
will Windows Paint. Still I get a Stream Read Error when trying to load the
bmp in a TBitmap.

Does anyone recognize this?
Yes, it is a bug in Photoshop. To work around it, copy graphics.pas to
the folder of your project, and perform the following (taken from my
previous post on this issue):
In TBitmap.ReadDIB, find this line:
// biSizeImage can be zero. If zero, compute the size.
if biSizeImage = 0 then // top-down DIBs have negative height
Replace the if statement with this:
if (bmiHeader.biCompression = BI_RGB) then
this will force it to calculate the correct value for all
non-compressed RGB images, which should work always (as an RGB image
is per definition uncompressed, it just a matter of arithmetics).
- Asbjørn
 

Re:TBipmap won't load .bmp saved with photoshop

Thanks Lord Crc,
That did it! I can read the bitmap now.
Hert
----------------------------------------------------
"Lord Crc" <XXXX@XXXXX.COM>writes
Quote
On Wed, 16 Jun 2004 22:25:16 +0200, "Hertwig" <XXXX@XXXXX.COM>
writes:

>I have a problem with the TBitmap. It appears it won't load .bmp files
that
>are created using Photoshop (notmap RGB photo). PaintShop will read it as
>will Windows Paint. Still I get a Stream Read Error when trying to load
the
>bmp in a TBitmap.
>
>Does anyone recognize this?

Yes, it is a bug in Photoshop. To work around it, copy graphics.pas to
the folder of your project, and perform the following (taken from my
previous post on this issue):

In TBitmap.ReadDIB, find this line:

// biSizeImage can be zero. If zero, compute the size.
if biSizeImage = 0 then // top-down DIBs have negative height

Replace the if statement with this:

if (bmiHeader.biCompression = BI_RGB) then

this will force it to calculate the correct value for all
non-compressed RGB images, which should work always (as an RGB image
is per definition uncompressed, it just a matter of arithmetics).

- Asbjørn