T O P I C R E V I E W |
aleatprog |
Posted - Oct 01 2018 : 02:36:12 My application processes e.g. PDF, TIF and JPG images.
A) In case of JPG or TIF, I load the image with Batch.MIO.LoadFromFile(path) and save it e.g. with Batch.MIO.SaveToFileTIFF(path) or Batch.MIO.SaveToFilePDF(path) without any problems.
B) In case of PDF, I create a TBitmap and fill it with the rendered PDF image (Bitmap := Pdf.RenderPage(0,0,Pdf.PageWidth,Pdf.PageHeight)). As result, ImageEnMView shows the Bitmap with the correct colors and proportions. But saving this Bitmap with Batch.MIO.SaveToFileTIFF(path) the TIF file is empty (size property = 0 byte), and saving it with Batch.MIO.SaveToFilePDF(path) the PDF file contains an image with wrong colors and proportions.
As A) works, maybe I miss something while creating the Bitmap in process B).
Any ideas what could cause the output problem, maybe missing parameters or similar? |
8 L A T E S T R E P L I E S (Newest First) |
aleatprog |
Posted - Nov 05 2018 : 06:29:17 Hi Nigel, setting the PixelFormat to 24bit the bitmap is saved correctly. Thank you for the hint. :) |
xequte |
Posted - Oct 02 2018 : 18:40:53 Yes, but please confirm what is the value of TBitmap.PixelFormat. It should not be pfDevice.
Nigel Xequte Software www.imageen.com
|
aleatprog |
Posted - Oct 02 2018 : 16:18:34 BitsPerSample and SamplesPerPixel are identical for both, bitmaps load from JPG/TIF and bitmaps from PDF passed by Pdfium.
Meanwhile I wrote a PDF Export function which saves the single bitmaps from TImageEnMView to file using the ImageEnMView.GetTIEBitmap.Write function, and reassempling the PDF page per page. This works for both bitmap sources. |
xequte |
Posted - Oct 02 2018 : 15:03:58 Most importantly, what is the Bitmap.PixelFormat value after the PDF.Render call?
Nigel Xequte Software www.imageen.com
|
aleatprog |
Posted - Oct 02 2018 : 06:10:57 This is exactly the point: The bitmap looks perfect in TImageEnMView but not in the PDF file saved by TImageEnMView.
I created some simple demos using a JPG image and all run fine.
As I wrote in the opening post, without the usage of Pdfium, the quality of the bitmap inside TImageEnView and the saved file are both perfect. The problem starts with the rendering process of Pdfium.
The image below shows in the upper part the rendering result in TImageEnMView (color + size ok) and in the lower part the PDF file saved by TImageEnMView (b/n, stretched).
Are there any parameters I may add to the TImageEnMView MIO.SaveToFileTIFF and MIO.SaveToFilePDF process in order to guarantee that the shown bitmap in TImageEnMView got the same properties as the bitmap inside the file saved by TImageEnMView?
|
xequte |
Posted - Oct 02 2018 : 02:01:10 I cannot see anything wrong in your code. I assume the page looks OK in the TImageEnMView?
Are you able to create a simple demo that shows it, and email it to us (replacing the pdfium code with some generic bitmap painting code).
Nigel Xequte Software www.imageen.com
|
aleatprog |
Posted - Oct 01 2018 : 17:25:27 PDF support by Pdfium.
procedure TformMain.Button1Click(Sender: TObject);
var
i: Integer;
Bitmap: TBitmap;
begin
if OpenDialog.Execute then
begin
Pdf.FileName := OpenDialog.FileName;
Pdf.Active := True;
try
for i := 1 to Pdf.PageCount do
begin
Pdf.PageNumber := i;
Bitmap := Pdf.RenderPage(0,0,Round(Pdf.PageWidth),Round(Pdf.PageHeight));
try
Batch.AppendImage(Bitmap);
finally
FreeAndNil(Bitmap);
end;
end;
finally
Pdf.PageNumber := 1;
Pdf.Active := False;
end;
end;
end; |
xequte |
Posted - Oct 01 2018 : 14:27:24 Hi
Please show your full code for B, loading a PDF, rendering it to a bitmap and assigning the bitmap to the TImageEnMView.
Also, what plug-in do you use for PDF support?
Nigel Xequte Software www.imageen.com
|