Board index » delphi » Delphi4 Graphics.pas bug fix

Delphi4 Graphics.pas bug fix

"Joe C. Hecht" <joehe...@code4sale.com> wrote in message news:3ac14b20$1_2@dnews...

Quote
> Bad... very bad :(
> Delphi 4, graphics.pas Line 3063 and 3064:

Joe, this likely explains why a number have reported problems with palettes with 3rd party products.
Another good reason for avoiding palettes. <g>

efg

 

Re:Delphi4 Graphics.pas bug fix


Bad... very bad :(

Bitmaps with palettes having a stated number of colors
other than the default, will save incorrectly, and will crash
(or refuse to load) in a number of industry standard graphics
applications:

Delphi 4, graphics.pas Line 3063 and 3064:

    InfoHeaderSize := SizeOf(TBitmapInfoHeader) + SizeOf(TRGBQuad) *
      (1 shl BI.biBitCount);

Fixed in Delphi 5:

      InfoHeaderSize := SizeOf(TBitmapInfoHeader) +
        SizeOf(TRGBQuad) * BI.biClrUsed;

Joe
--
John Kaster is cycling to cure cancer! Lets help him out! http://homepages.borland.com/jkaster/tnt/

Re:Delphi4 Graphics.pas bug fix


Quote
"Joe C. Hecht" wrote:

> Bitmaps with palettes having a stated number of colors
> other than the default, will save incorrectly, and will crash
> (or refuse to load) in a number of industry standard graphics
> applications:

> Fixed in Delphi 5:

What about Delphi3, is this still an error?

The line/s are:

    InfoHeaderSize := SizeOf(TBitmapInfoHeader);
    if (BI.biCompression and BI_BITFIELDS) <> 0 then
      Inc(InfoHeaderSize, 12);

--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia

Re:Delphi4 Graphics.pas bug fix


Quote
> What about Delphi3, is this still an error?

> The line/s are:

>     InfoHeaderSize := SizeOf(TBitmapInfoHeader);
>     if (BI.biCompression and BI_BITFIELDS) <> 0 then
>       Inc(InfoHeaderSize, 12);

Look down a couple of more lines of code, and you
will see the error exists in the D3 graphics.pas file
(at least the one that is from the CD... I doubt the
patches touched it).

John Kaster is cycling to cure cancer! Lets help him out! http://homepages.borland.com/jkaster/tnt

Re:Delphi4 Graphics.pas bug fix


Quote
> "Joe C. Hecht" <joehe...@code4sale.com> wrote in message news:3ac14b20$1_2@dnews...
> > Bad... very bad :(

> > Delphi 4, graphics.pas Line 3063 and 3064:

"Earl F. Glynn" <EarlGl...@att.net> wrote in message news:3ac153c3$1_1@dnews...

Quote
> Joe, this likely explains why a number have reported problems with palettes with 3rd party products.
> Another good reason for avoiding palettes. <g>

Ok... I caught a lot of flack not too long ago for my "opinions" on graphics.pas...

I would say this is another good reason for avoiding using graphics.pas
for anything serious<g>

--
John Kaster is cycling to cure cancer! Lets help him out! http://homepages.borland.com/jkaster/tnt/

Re:Delphi4 Graphics.pas bug fix


Quote
> Joe, In my own code I noticed an error when 16-bit video was used.  It may
> be the same problem as you have just reported.  In any case, I found a
> simple fix:

>   // There appears to be a problem with 16-bit video where
>   // a "20" is inserted for the number of colours used.
>   // Forcing the palette to zero seems to fix this....
>   if bmp.PixelFormat = pf24bit then bmp.Palette := 0;

Interesting fix. I do know it is perfectly legal to have
a optional color table for a 15,16,24, and 32 BBP
bitmap, but I am pretty sure the VCL does not
support it.

In general, since I left Borland, I quit debugging graphics.pas
(unless a paying customer absolutly instists). I cant say I have
missed it either<g>

--
John Kaster is cycling to cure cancer! Lets help him out! http://homepages.borland.com/jkaster/tnt/

Re:Delphi4 Graphics.pas bug fix


Joe, In my own code I noticed an error when 16-bit video was used.  It may
be the same problem as you have just reported.  In any case, I found a
simple fix:

  // There appears to be a problem with 16-bit video where
  // a "20" is inserted for the number of colours used.
  // Forcing the palette to zero seems to fix this....
  if bmp.PixelFormat = pf24bit then bmp.Palette := 0;

David

"Joe C. Hecht" <joehe...@code4sale.com> wrote in message
news:3ac14b20$1_2@dnews...

Quote
> Bad... very bad :(

> Bitmaps with palettes having a stated number of colors
> other than the default, will save incorrectly, and will crash
> (or refuse to load) in a number of industry standard graphics
> applications:

> Delphi 4, graphics.pas Line 3063 and 3064:

>     InfoHeaderSize := SizeOf(TBitmapInfoHeader) + SizeOf(TRGBQuad) *
>       (1 shl BI.biBitCount);

> Fixed in Delphi 5:

>       InfoHeaderSize := SizeOf(TBitmapInfoHeader) +
>         SizeOf(TRGBQuad) * BI.biClrUsed;

> Joe

Re:Delphi4 Graphics.pas bug fix


Joe C. Hecht <joehe...@code4sale.com> wrote in message 3ac194c8_1@dnews...

Quote
> > Joe, In my own code I noticed an error when 16-bit video was used.  It
may
> > be the same problem as you have just reported.  In any case, I found a
> > simple fix:

> >   // There appears to be a problem with 16-bit video where
> >   // a "20" is inserted for the number of colours used.
> >   // Forcing the palette to zero seems to fix this....
> >   if bmp.PixelFormat = pf24bit then bmp.Palette := 0;

> Interesting fix. I do know it is perfectly legal to have
> a optional color table for a 15,16,24, and 32 BBP
> bitmap, but I am pretty sure the VCL does not
> support it.

> In general, since I left Borland, I quit debugging graphics.pas
> (unless a paying customer absolutly instists). I cant say I have
> missed it either<g>

> --
> John Kaster is cycling to cure cancer! Lets help him out!

http://homepages.borland.com/jkaster/tnt/
Quote

Joe , would it be difficult for You (with your experience) create a new
Tbitmap class that supports the following things:
1) big bitmap support
2) At least 24 bit pixel format support
3) scanline access (like that already present in Delphi)
It would not make difference if the new class implements or not some gdi
methods (infact using scanline one could implement the other methods by
himself) .
What about? I think that such class would be a good selling for you and a
good buying for the Delphi developers that want to do some proof graphics .
Of course also the units you are actually selling are useful but it would be
great have a unit to manipulate bitmaps in a better way than actually VCL
does .
Thanx , Francesco .

Re:Delphi4 Graphics.pas bug fix


Quote
> Joe , would it be difficult for You (with your experience) create a new
> Tbitmap class that supports the following things:
> 1) big bitmap support
> 2) At least 24 bit pixel format support
> 3) scanline access (like that already present in Delphi)

Hi Francesco!

I have such a unit. It supports DIBs as large as memory
allows, and can blt and stretchblt between dibs of different
formats using zero GDDI functions, supports all dib formats,
has scanline access, has a way to request a scanline in 24
bit format from any dib format (ie 8>24), then push a 24
scanline to any dib format (ie 24>8), supports JPEGs
(with the pro/clientserver versions of Delphi), supports
TWAIN (aquiring DIBS from scanners, digital cameras
and the like), have superior (consistant) palette handeling
across machines/os/harware/drivers, and is about 8000
lines of code. Documentation is held in a single doc file,
and is a bit sparse.

I sell this unit privatly upon request, and has been used
in various commercial apps over the past few years.

I do not sell it publically. I feel better docs are in order,
and to be truthfull, our tech support often goes way
beyond the call of duty with customer requests, and
I just do not have the time to dedicate to support
all the questions and custom uses folks (in quantity)
often desire.

There is some hope... I have thought about doing an
open source version....

Joe

Re:Delphi4 Graphics.pas bug fix


"Joe C. Hecht" <joehe...@code4sale.com> a crit dans le message news:
3ac14b20$1_2@dnews...

Quote
> Bad... very bad :(

> Bitmaps with palettes having a stated number of colors
> other than the default, will save incorrectly, and will crash
> (or refuse to load) in a number of industry standard graphics
> applications:
> Fixed in Delphi 5:

>       InfoHeaderSize := SizeOf(TBitmapInfoHeader) +
>         SizeOf(TRGBQuad) * BI.biClrUsed;

After reading the replies since your message I'm a little wary of sticking my head up
among you Graphic gurus. Boy you can be FRIGHTENING.

I'm not at a level therefore where I have to w<orry too much about palettes but you
never know and I like to keep a note of these things.

I'm on Delphi 4 pro. Is there anything to stop me changing Graphics.pas and
incorporating this update. I suppose not, but I'd like to make sure in case I do it,
forget about it and wonder why, in future times, my super whiz graphics routine keeps
throwing up errors.

Thanks in advance

John

Other Threads