Hello,
I'm using the wxPdfDC Blit method to print an arc outline. It works perfectly when I print to the screen using wxDC but when
I print to a PDF using the wxPdfDC , it displays a black rectangle with the arc inside.
How do I blit to pdf so the bitmap rectangle background is transparent. I'm using the Alpha channel to make the
pixels inside the arc and outside the arc outline transparent.
See attached images.
Thank you.
RSB
Problems with Blit
Problems with Blit
- Attachments
-
- ArcPDF.PNG (12.29 KiB) Viewed 16944 times
-
- ArcScreen.PNG (5.77 KiB) Viewed 16944 times
Re: Problems with Blit
Please keep in mind that PDF is a vector graphics format, while on screen you have a pixel graphics format. Blit only works on pixel graphics. That is, you may Blit from a screen wxDC to wxPdfDC, but Blit from wxPdfDC to wxPdfDC is not supported, because PDF does not have a pixel graphic from which you could Blit.
Why don't you draw the arc outline directly? I really don't understand why you need a Blit operation for this purpose.
Re: Problems with Blit
Thanks Utelle,
Is there an easy way to do this?
Thanks.
Okay.Utelle wrote: |
Please keep in mind that PDF is a vector graphics format, while on screen you have a pixel graphics format.
We're trying to draw the outline of the arc only as in the second picture with the internal pixels transparent.Utelle wrote: |
Why don't you draw the arc outline directly?
Is there an easy way to do this?
Thanks.
Re: Problems with Blit
In principle it should be possible to achieve this by using the wxDC::DrawArc method.
Could you please provide some code how you currently produce the intended graphic? Then I might be able to show a way how to accomplish the same result with wxPdfDC.
Re: Problems with Blit
See attached file. Basically it draws a filled arc, then sets all pixels inside the arc
outline to transparent.
I was able to get this to work by using DrawBitmap instead of Blit but it's very slow.
Thanks very much.
outline to transparent.
I was able to get this to work by using DrawBitmap instead of Blit but it's very slow.
Thanks very much.
- Attachments
-
- draw_arc_outline.txt
- (4.95 KiB) Downloaded 299 times
Re: Problems with Blit
As said pixel operations won't work for wxPdfDC.
I'll take a look. If I can come up with a feasible approach I'll let you know. Please allow some time for further inspection.
Re: Problems with Blit
I would recommend that you explicitly draw the outline of the requested arc. For this you will have to determine the start and end points for the inner and outer outline of the arc (depending on the path width of the arc) using an appropriate line width.
Additionally, for connecting the end points of the inner and outer arc you need to determine the cap style, that is, you connect the points either with straight lines or half circles.
This approach allows you to get rid of bitmap operations which are not supported for wxPdfDC.
Code: Select all
DrawArc(startXouter, startYouter, endXouter, endYouter, centerX, centerY);
DrawArc(startXinner, startYinner, endXinner, endYinner, centerX, centerY);
This approach allows you to get rid of bitmap operations which are not supported for wxPdfDC.
Re: Problems with Blit
Thanks Utelle,
The approach you recommended is what we were doing, it looks good in PDF but not good
when drawing to the screen using a wxDC which is why we were looking for a new solution.
It's really hard to get the end caps (half circles) to line up with the arc endpoints.
So we will just use one method (your method) for PDF and another method (Bitmap/Image) for
drawing to the screen.
Thanks for looking at this!
RSB
The approach you recommended is what we were doing, it looks good in PDF but not good
when drawing to the screen using a wxDC which is why we were looking for a new solution.
It's really hard to get the end caps (half circles) to line up with the arc endpoints.
So we will just use one method (your method) for PDF and another method (Bitmap/Image) for
drawing to the screen.
Thanks for looking at this!
RSB
Re: Problems with Blit
Yes, due to the integer coordinate system of wxDC such operations can get very difficult.
Most likely using wxGraphicsContext would be easier. However, up to now wxPdfDocument does not yet offer support for wxGraphicsContext, although this task has been on my to-do list for quite a long time.
That's probably the best possible approach for now.
You are welcome.