Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
Displaying transparent BMP Files |
Post Reply |
Author | |
mcinelly1
Beginner Joined: 09 Mar 11 Location: USA Status: Offline Points: 7 |
Post Options
Thanks(0)
Posted: 24 May 12 at 10:27PM |
Hi,
I'm trying to display a monochrome bmp file (a scanned signature) over the top of my pdf file. I'm trying to get the white area of the bmp to be transparent. Following previous posts I found reference to the SetImageAsMask() and SetImageMask() functions. Using the following code: int iResult = qp->AddImageFromFile(WideString(sSigPath).c_bstr(), 1); qp->SelectPage(iImagePageNumber); qp->SelectImage(iResult); qp->SetImageMask(0); // or qp->SetImageMask(1) qp->DrawImage(iImageLeft, iImageTop + (iImageHeight * .5), iImageWidth, iImageHeight * 2); I get a completely white graphic - the black signature is being filtered out. if I replace qp->SetImageMask(0) with something like qp->SetImageAsMask(0,0,0,.5,.5,.5) (or pretty much any other values) I can get a few pixels of black - but it is mostly filtered out too. Are there any special considerations for the BMP type, other than monochrome? The sample bmp file can be downloaded from www.agencysoftware.com/test.bmp Thanks in advance for your help. Mitch McInelly |
|
mcinelly1
Beginner Joined: 09 Mar 11 Location: USA Status: Offline Points: 7 |
Post Options
Thanks(0)
|
Sorry. I should also say that I am using C++ Builder 6 and QuickPDFDLL0812.dll
Thanks, Mitch McInelly
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi Mitch!
You should try the newest dll first. The kind of work you described was improved with each new version. Actually we've 8.15 ;-) Cheers, Ingo |
|
mcinelly1
Beginner Joined: 09 Mar 11 Location: USA Status: Offline Points: 7 |
Post Options
Thanks(0)
|
I installed 8.15 this morning and I have the same results. SetImageAsMask(0) does not make white background transparent. SetImageAsMask(1) makes pretty much entire BMP transparent - not showing black lines. I triple checked that my file was a black & white bmp.
Thanks
|
|
barqyDev
Beginner Joined: 10 Feb 12 Status: Offline Points: 7 |
Post Options
Thanks(0)
|
I had some problems with BMP, so I converted to PNG (no transparency though).
I was not able to get the SetPNGTransparencyColor() to work, but
SetImageMask() seems like it can work for you. I put a range of 90% = 100%, but if the image really is monochrome, you should be able to use all 1's for the starting/ending color. edited...I used AddImageFromFile(L"test.png", 0) int iResult = qp->AddImageFromFile(WideString(sSigPath).c_bstr(), 1); qp->SelectPage(iImagePageNumber); qp->SelectImage(iResult); qp->SetImageMask( 0.9, 0.9, 0.9, 1, 1, 1 ); // THIS SHOULD WORK FOR YOU qp->DrawImage(iImageLeft, iImageTop + (iImageHeight * .5), iImageWidth, iImageHeight * 2); Edited by barqyDev - 27 May 12 at 9:03PM |
|
kaiken1987
Beginner Joined: 27 Jan 12 Location: United States Status: Offline Points: 5 |
Post Options
Thanks(0)
|
barqyDev, thanks I was also having a problem doing this and at it fixed it
|
|
mcinelly1
Beginner Joined: 09 Mar 11 Location: USA Status: Offline Points: 7 |
Post Options
Thanks(0)
|
I could not get this to work for monochrome bitmap images. I would up having to convert the monochromes to 256 color images as follows:
//SignControl3 is a monochrome bitmap //SignControl2 is predefined 256 color palette SignControl3->Picture->LoadFromFile(OpenPictureDialog->FileName); SignControl2->Width = SignControl3->Width; SignControl2->Height = SignControl3->Height; TRect src = Rect(0,0, SignControl3->Width, SignControl3->Height); TRect dest = Rect(0, 0,SignControl2->Picture->Bitmap->Width, SignControl2->Picture->Bitmap- >Height); SignControl2->Picture->Bitmap->Canvas->CopyRect(dest, SignControl3->Canvas, src); SignControl2->Picture->SaveToFile(OpenPictureDialog->FileName); SignControl->Picture->LoadFromFile(OpenPictureDialog->FileName);
|
|
barqyDev
Beginner Joined: 10 Feb 12 Status: Offline Points: 7 |
Post Options
Thanks(0)
|
mcinelly1, I understand you've got a solution going. If you can provide a link to the (or a) mono bitmap, I'm interested in tinkering with it. Seems like there should be an easier way than to convert the file and reload it.
|
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
This code is working correctly using the 8.16 release. It creates a problem with the 8.15 release so it looks like there was a bug fix in the 8.16 release that allows this to work correctly. 8.16 is a free upgrade from 8.xx and can be downloaded from http://www.debenu.com/products/development/debenu-pdf-library/updates/ QP.SetOrigin(1); QP.SetLineWidth(2); for (int i = 1; i <= 16; i++) { QP.SetLineColor(0, (double)i / 16, (double)i / 16); QP.DrawLine(i * 16, 0, i * 16, 200); } int img = QP.AddImageFromFile("test.bmp", -1); QP.SelectImage(img); QP.SetImageMask(0.9, 0.9, 0.9, 1, 1, 1); // THIS SHOULD WORK FOR YOU QP.DrawImage(0,0, 100, 100); QP.SaveToFile("out.pdf"); It seems that when using the code above - AcrobatX does some interesting things when rendering this file. If the zoom is less than 100% then a white box is drawn under the signature. Zooming in then shows the correct background. I beleive this is an Acrobat rendering problem. Another option is to call QP.SetBlendMode(3); before calling DrawImage and then calling QP.SetBlendMode(0); Currenty QuickPDF Library cannot render blend modes but we are working to add this feature. Andrew. Edited by AndrewC - 12 Sep 12 at 5:37AM |
|
myler
Beginner Joined: 13 Sep 12 Location: ITALY Status: Offline Points: 2 |
Post Options
Thanks(0)
|
Hi mcinelly1!
I saw that you are working with C++Builder 6. Can I ask you some suggestions in order to install QPL onto C++ Builder? I tried to work with the Active X but when I try to unlock the component I get "0" as result instead of 1. Maybe I made some mistake when I've imported the type library( I do not know). Now I'm trying to use the DLL but I don't know if it is a good idea... Thanks in advance, Erio |
|
Wheeley
Senior Member Joined: 30 Oct 05 Location: United States Status: Offline Points: 146 |
Post Options
Thanks(0)
|
As you work out your troubles one difference to keep in mind is that any computer you want to run your application on will need to register the ActiveX. You don't have this issue with the DLL.
Wheeley |
|
myler
Beginner Joined: 13 Sep 12 Location: ITALY Status: Offline Points: 2 |
Post Options
Thanks(0)
|
Thanks a lot Wheeley. I agree with your reply. I supposed that ActiveX was faster in order to develop the application than DLL.
|
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
Here is some BCB6 code that should help you to load the DLL version. Make sure the QuickPDFDLL0816.DLL file is in the same directory as your compiled EXE or on the Windows path somewhere. 8.xx uses unicode strings hence the L prefix.
#include <vcl.h> #pragma hdrstop #include "Unit1.h" #include "stdio.h" #include "stdlib.h" #include "dir.h" #include "mem.h" #include "io.h" #include "strutils.hpp" #include "QuickPDFdll0816.cpp" QuickPDFDLL0816 QP(L"quickpdfdll0816.dll"); #include <string> using namespace std; //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { int InstanceID; chdir("f:\\users\\andrew\\downloads"); wstring s = L"<insert your licence key here>"; std::wstring lv = QP.LibraryVersion(); if (QP.UnlockKey(s) != 1) MessageBox(Handle, "QPL License Key not valid", "Warning", MB_OK); Text = lv.c_str(); // Set the Window Title to the version number. int ret = QP.ImportEMFFromFile(L"aaa.emf", 0, 0); } |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store