SOS!!Again about Print Black Rectangle!!

;)
I have searched the topics in the old forum of the site.

1. http://www.fast-report.com/en/answer_forum.php?id=658&n_id=4
Why appears black images in a TfrPictureView, sometimes?

2. http://66.227.63.207/en/answer_forum.php?id=82&n_id=4
Problems with tfrPictureView class

now,i have the same problem in WINXP system, but i can't find a solution from the site. Tell me how to fix the problem and which way is the best and fastest....... the Boss is angry and customers are already very angry... help me,thx!!

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 7:42AM
    This problem seems to be a very intermitent thing.I haven't been able to reproduce it on my own or customers systems.
    need all the info you can give
    customer environment- op system, printer, printer driver vers, vidcard and mem, system mem, network printer or local,
    report- does it produce a large number of pages,
    development system- os, ide ver.
    regards ;)
  • edited 7:42AM
    hi,

    i had this kind of problem too (but with QR)
    it seems that using GlobalAlloc is safer than AllocMem.. and
    that FR and QR use AllocMem.

    here reply from Adam Johnston - thank to him - on the
    borland newsgroup.

    Hope this can help
    LooL



    -I changed the PrintBitmap routine to the following and it fixed the problem
    -on my machine. There's a problem with AllocMem memory being trashed
    -apparently (credit to whoever worked it out) so use GlobalAlloc.

    -Regards
    -AJAY

    -{ TQRImage }

    - procedure PrintBitmap(aCanvas : TCanvas; Dest : TRect; Bitmap : TBitmap);
    - var
    - Info : PBitmapInfo;
    - InfoSize : DWORD;
    - Image : Pointer;
    -//
    -// PATCH: MEMORY ALLOCATION PROBLEM
    -//
    -//
    - HInfo:HGLOBAL; //Declare this new var
    - HImage:HGLOBAL; //Declare this new var
    -//
    -// PATCH: END
    -//
    -//
    -{$ifdef ver80}
    - ImageSize : Longint;
    -{$else}
    - ImageSize : DWord;
    {$endif}
    begin
    with Bitmap do
    begin
    GetDIBSizes(Handle, InfoSize, ImageSize);
    //
    // PATCH: MEMORY ALLOCATION PROBLEM
    //
    //
    // This is the source of the problem. AllocMem allocates a memory block on
    the
    // heap but windows sometimes (expecially during slow down) needs to move to
    // another area. The pointer is not updated so quick report prints a black
    box.
    //
    // Info := AllocMem(InfoSize);
    //
    // The GlobalAlloc function allocates memory on the heap(This Win32 API
    // doesn't make difference between local and global heap)
    // The second line is the most important. We lock the memory allocated so
    that
    // windows will never move it and our bitmap pointer will always point to
    the
    // right memory address.
    //
    HInfo := GlobalAlloc(GMEM_MOVEABLE or GMEM_SHARE,InfoSize);
    Info := PBitmapInfo(GlobalLock(HInfo));
    //
    // PATCH: END
    //
    //
    try
    //
    // PATCH: MEMORY ALLOCATION PROBLEM
    //
    //
    // Image := AllocMem(ImageSize);
    //
    HImage := GlobalAlloc(GMEM_MOVEABLE or GMEM_SHARE,ImageSize);
    Image := Pointer(GlobalLock(HImage));
    //
    // PATCH: END
    //
    //
    try
    GetDIB(Handle, Palette, Info^, Image^);
    if not Monochrome then
    SetStretchBltMode(ACanvas.Handle, STRETCH_DELETESCANS);
    with Info^.bmiHeader do
    StretchDIBits(aCanvas.Handle, Dest.Left, Dest.Top,
    Dest.RIght - Dest.Left, Dest.Bottom - Dest.Top,
    0, 0, biWidth, biHeight, Image, Info^, DIB_RGB_COLORS,
    SRCCOPY);
    finally
    //
    // PATCH: MEMORY ALLOCATION PROBLEM
    //
    //
    // FreeMem(Image, ImageSize);
    GlobalUnlock(HImage); // We first unlock the previously
    locked memory
    GlobalFree(HImage); // and then we free it
    //
    // PATCH: END
    //
    //
    end;
    finally
    //
    // PATCH: MEMORY ALLOCATION PROBLEM
    //
    //
    // FreeMem(Info, InfoSize);
    GlobalUnlock(HInfo); // We first unlock the previously
    locked memory
    GlobalFree(HInfo); // and then we free it
    //
    // PATCH: END
    //
    //
    end;
    end;
    end;


    <user@domain.invalid> wrote in message
    news:3f98fb5d@newsgroups.borland.com...

    > same problem exist when printing images Delphi6 + FastReport2.5 + HP
    > printers + W2K/XP ???,
    >
    > is the bug in Delphi routines, or interfaces to Windows???
    > image processing code in QR and FR is identical - GetDIBits,
    > StrechDIBits, ...
    >
    > Adam Johnston wrote:

    > > Its a bug in Quick Reports PrintBitmap code thats been there for years

    and

    > > they haven't bothered to fix. You will need to buy the Pro update to

    get

    > > the source code then patch manually.

    >

    > >>I have a problem printing a report with a QRImage. Sometimes the QRImage
    > >>print all in black. The image have bmp format, and low resolution (is a
    > >>enterprise logo).

    >
  • edited 7:42AM
    try fr2.51

    in fr2.51 TfrPictureView.Draw had been changed,it use GlobalAlloc for TBitmap and
    TJPEG
  • ggmggm
    edited 7:42AM
    gordk wrote:
    This problem seems to be a very intermitent thing.I haven't been able to reproduce it on my own or customers systems.
    need all the info you can give
    customer environment- op system, printer, printer driver vers, vidcard and mem, system mem, network printer or local,
    report- does it produce a large number of pages,
    development system- os, ide ver.
    regards ;)
    thanks for your regards,
    1、About the customer environment:
    OS: WinXP Professional(Service Pack 1)
    Printer: HP Deskjet 3420 series
    Printer driver vers:unknown
    System mem:256M
    Video card: 10Moons video baby(Bt878 compatible)
    local Printer
    2、Report:
    the largest images number of the Report is: 4
    with JPEG format and the size is 800X600
    the black rectangle is also appear while the selected images number is 2 or 3.
    3、development system:
    OS:WinXP Professional(Service Pack 1)
    IDE:DELPHI Enterprise 6
    FastReport:2.50
  • binarybinary South Africa
    edited 7:42AM
    ;) Hi I had the same problem all I did was change the BMP to a WMF and the problem never came back on XP.
  • SamuraySamuray Administrator
    edited 7:42AM
    Use FastReport 2.51, this problem in many events has fixed.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.