TPreview v4.74

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

TPreview v4.74

Postby beinars » October 19th, 2010, 11:28 am

Hi there and thanks again for this great product..

I have been using this unit with some modification, which are mostly towards report abilities or higher level use. Until now I haven't sunk myself into the deep forest of this code.

I have stumped onto wall, as in some cases where graphic (bitmap) printing results as black box! This happens even with only when printing one page.

It looks like as it relates to the size of the bitmap somehow. I have tried to search for this kind of problem here on this forum, but with no luck.

As I said, I suspect this problem relates to "upload time", size and even printer more than this code or methods using when printing. Quick glans at the problem points out HP-printers more than others brand. But the stat set is of low value, under 10 individuals.

If you have any suggestion I would appreciate it very much.

ps. ..isn't possible to donate some $$
beinars
Active Member
Active Member
 
Posts: 12
Joined: May 3rd, 2007, 9:38 am
Location: Iceland

Re: TPreview v4.74

Postby Kambiz » October 19th, 2010, 12:57 pm

Do you use PaintGraphic, PaintGraphicEx, or PaintGraphicEx2 method to draw the bitmaps? If the answer is positive, please send me one the bitmaps, so that I can investigate the problem.

By the way, why using v4.74? The latest version is v5.5! Instead of modification, if you drive your own preview class from TPrintPreview, you can always use the latest version of the component, mostly without need to revise your code.

Thanks for offering $! I'm leaving in an isolated country, and no financial interaction with the outside world is possible.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: TPreview v4.74

Postby beinars » October 19th, 2010, 2:14 pm

Tanks Kambiz

I use this function: PaintGraphicEx (R_To, Image1.Picture.Graphic, false, False, false);

As you can see I send Graphic as parameter.

That function use this code to print graphic:

Code: Select all
    Bitmap := TBitmap.Create;
    try
      Bitmap.Canvas.Brush.Color := clFuchsia;
      Bitmap.Width := Graphic.Width;
      Bitmap.Height := Graphic.Height;
      Bitmap.Canvas.Draw(0, 0, Graphic);
      Bitmap.Transparent := Graphic.Transparent;
      DrawBitmapAsDIB(Canvas.Handle, Bitmap, Rect)
    finally
      Bitmap.Free;
    end;


And by the way. It doesn't happen every time of printing. Indeed it happens rather rarely, which why I can't debug it and solve it by myself.

And I will download the newest version. Most likely I will update my version by using source comparison as I see I have modified the TPreview comp in some cases.. and perhaps most likely to worse!

Again, thanks!
beinars
Active Member
Active Member
 
Posts: 12
Joined: May 3rd, 2007, 9:38 am
Location: Iceland

Re: TPreview v4.74

Postby Kambiz » October 19th, 2010, 5:02 pm

I can see that the problem is because of image transparency.

First, make sure AllowTransparentDIB global variable (declared in Preview.pas) is set to False.

After that, either set background color of your bitmap to white and set its Transparent property to False, or use these steps to draw the bitmap properly:

  1. Create a temporary bitmap as size as the original one
  2. Fill the background of the temporary bitmap with white color
  3. Draw the original bitmap on the temporary one
  4. Draw the temporary bitmap on the print preview's canvas
  5. Free the temporary bitmap

FYI, I just uploaded a new release of the component.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: TPreview v4.74

Postby beinars » November 30th, 2010, 12:44 am

Thanks Kambiz

I think I have found the root of the problem. Next is the cure :? As I did say, I'm printing logo's from BMP and JPG files. In bigger systems I keep the graphics files on Server, central in one place. That seams to mean some delay when reading the files, and exactly that delay seems to be the root of the problem.

I have now moved the files onto local drives and the frequency of "black boxes" has reduced dramatically. But, it still happens but now in very rare occasions.

Sincerely beinars
beinars
Active Member
Active Member
 
Posts: 12
Joined: May 3rd, 2007, 9:38 am
Location: Iceland

Re: TPreview v4.74

Postby beinars » December 2nd, 2010, 1:52 am

Hi..

I have been digging a lot.

Found this comment on one forum (Embaracadero):

Using it together with drawing on not "Delphi canvas" you can have very weird/random unexpected
results.
The thing i saw most, was filled black boxes printed (to a PDF canvas or Printer canvas) instead of
the image. Unfortuanlly it happens randomly and is very difficult to reproduce. Ofcourse these
black boxes appear mostly by clients and not at your developing machines :(

I was strungling with this problem for many years and never couldn't find the real problem, tried
all kind of routines that said to be the solution to printer problems, but none of them were the
solution. (Also tried that TExcellentPrinterThingy, but waste of money).

Solution now seems to be simple, just using another GetMem routine and that sounds also quite logic
after all, cause the problems happen more often under "bad memory" circumstances.

I prefer to warn for those ugly bugs where you couldn't get your hand on. Cost me many years of
frustration (ok, not every day ;-) to fix this, so if i can save someone else with this garbage...

Regards,
Arno Brinkman
ABVisie

Will let you know if this is the solution!
beinars
Active Member
Active Member
 
Posts: 12
Joined: May 3rd, 2007, 9:38 am
Location: Iceland

Re: TPreview v4.74

Postby Kambiz » December 2nd, 2010, 9:20 am

Sounds interesting!
I would be thankful to know the result.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 1 guest

cron