Print Page | Close Window

GetCanvasDC, Delphi, PatternBrush

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1327
Printed Date: 19 Apr 24 at 1:41AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: GetCanvasDC, Delphi, PatternBrush
Posted By: Detlev
Subject: GetCanvasDC, Delphi, PatternBrush
Date Posted: 28 Jan 10 at 2:15PM

Hallo,

I am re-writing a delphi function which originally draws textured rectangles with a patternbrush to a printer canvas. I have changed the printer.canvas.handle to the QP.GetCanvasDC. Nearly everything works fine, with the exception of the textures. The PDF shows only the borderlines.

The same bitmaps (1 bit or 4 color grayscale, it doesn't matter) can be drawn with QP.Drawimage w/o problems. They will also be drawn on a PaintBox.Canvas with the same GDI commands.

Has anybody an idea, how to solve this problem?

Detlev




Replies:
Posted By: DELBEKE
Date Posted: 28 Jan 10 at 2:46PM
Hi Detlev
 
At the momment, Quickpdf can't handle pattern-brushes. Perhaps you can use some plain grayed or colored brushes ?
 


Posted By: Detlev
Date Posted: 28 Jan 10 at 7:44PM

Hi Delbeke,

I use colored brushes too. I write a simple mapping application, therefore filling polygons with some kind of pattern is mandatory. Is it possible to use QP functions to "floodfill" rectangles with the selected image? Or do you know any library for filling closed areas with vector based pattern basically by tiling and clipping, like in Adobe Illustrator? (elementary pattern described by a kind of scripting language)



Posted By: DELBEKE
Date Posted: 29 Jan 10 at 12:49AM
Hi Detlev, can you contact me directly at  jean-luc(at)delbeke(point)fr


Posted By: fellafoo
Date Posted: 12 Jul 22 at 4:06PM
Hello,

I've been looking at this and I am stumped as well. I can use Windows.CreatePatternBrush or Windows.CreateHatchBrush and draw the fill onto a metafile canvas then use ImportEMFFromStream  to get the pattern fill onto the page, but that's a long way around.

Has anyone come up with a more-direct method?

Thank You,

MFM


Posted By: fellafoo
Date Posted: 12 Jul 22 at 9:01PM
This is what I've come up with so far. It seems to work.

function PDF_CreateSetTilingPattern(var PDFLib: TDebenuPDFLibrary; ImgFile: String; Page: Integer): Boolean;
{ Create and set a bitmap tiling pattern for filled boundaries. }
var
  ImageID, CaptureID: Integer;
  PatternName: WideString;

begin
  Result := False;

  { Add temporary page and select it. }
  PDFLib.NewPage;
  PDFLib.SelectPage(PDFLib.PageCount);

  { Load bitmap for tile pattern. }
  ImageID := PDFLib.AddImageFromFile(ImgFile, 0);

  { Set page dimensions in inches (bitmap pixels divided by dpi). }
  PDFLib.SetPageDimensions(PDFLib.ImageWidth / PrintPDF.Dpi.X, PDFLib.ImageHeight / PrintPDF.Dpi.X);

  { Select image and draw it to fill page. }
  PDFLib.SelectImage(ImageID);
  PDFLib.DrawImage(0, 0, PDFLib.PageWidth , PDFLib.PageHeight);
  //PDFLib.DrawRotatedImage(0, 0, PDFLib.PageWidth , PDFLib.PageHeight, 270)

  { Reset selected page }
  PDFLib.SelectPage(Page);

  { Capture last page and set pattern name. }
  CaptureID := PDFLib.CapturePage(PDFLib.PageCount);
  //CaptureID := PDFLib.CapturePageEx(PDFLib.PageCount, 0);
  PatternName := IntToStr(CaptureID) + '_' + ExtractFileName(ImgFile);

  PDFLib.NewTilingPatternFromCapturedPage(PatternName, CaptureID);

  PDFLib.DeletePages(PDFLib.PageCount, 1);

  Result := (PDFLib.SetFillTilingPattern(PatternName) = 1);
  //PDFLib.SetTilingPatternMatrix()
end; { PDF_CreateSetTilingPattern }



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk