|
-
Mar 5th, 2017, 03:44 PM
#27
Re: How to change the specified color in the picture to another color?
 Originally Posted by dilettante
Yeah, I didn't think that would be a magic bullet.
It might be worth trying the ClipBoard API so that pasting EMF+ is possible, but I'm not sure whether a StdPicture can even handle those anyway.
Those *.emz which are generated (on the ClipBoard, but also during HTML-export from Word),
are not "EMF+" (which is just a GDI+ applied antialiased rendering from normal EMF-records-enumerations) -
they are plain "GZip-compressed EMF-files".
@the OP
FWIW, here's a Cairo-based EMZtoPNG-converter (although we still don't know, what the whole exercise really is for).
Code:
Option Explicit
Private Sub Form_Load()
EMZ2PNG App.Path & "\image001.emz", App.Path & "\image001.png", 480
EMZ2PNG App.Path & "\image003.emz", App.Path & "\image003.png", 480
EMZ2PNG App.Path & "\image005.emz", App.Path & "\image005.png", 480
'now show a preview for one of the converted Images
Set Picture = Cairo.ImageList.AddImage("", App.Path & "\image003.png").Picture
End Sub
Private Sub EMZ2PNG(EMZFile As String, PNGFile As String, ByVal DstHeightPxl As Long)
Dim BCmp() As Byte, BDec() As Byte, EMFPage As cReportPage, Srf As cCairoSurface
BCmp = New_c.FSO.ReadByteContent(EMZFile) 'read the entire File into a Byte-Array
New_c.Crypt.GzDecompress BCmp, BDec 'decode the ByteArray with the GZ-Decompression-algo
'create a new ReportPage-instance (cReportPage is handling EMF internally)
Set EMFPage = New_c.ReportPage
EMFPage.EMFContent = BDec 'provide the GZ-Decoded EMF-bytes as the Page-content
'prepare an oversized Cairo-Surface for as a target for the EMF-rendering
Set Srf = Cairo.CreateWin32Surface(3.3 * DstHeightPxl * EMFPage.AspectRatio, 3.3 * DstHeightPxl)
Srf.CreateContext.Paint 1, Cairo.CreateSolidPatternLng(vbWhite)
EMFPage.RenderTo Srf.GetDC, 0, 0, Srf.Width, Srf.Height 'render the EMF onto the CairoSrf
With Srf.CreateContext 'correct the missing Alpha-Info on the just rendered EMF-content
.Operator = CAIRO_OPERATOR_DEST_ATOP
.Paint 1, Cairo.CreateSolidPatternLng(vbBlack)
End With
'finally a high-quality downstretching from the oversized Cairo-Surface to a smaller one
With Cairo.CreateSurface(DstHeightPxl * EMFPage.AspectRatio, DstHeightPxl).CreateContext
.RenderSurfaceContent Srf, 0, 0, .Surface.Width, .Surface.Height, CAIRO_FILTER_GAUSSIAN
.Surface.WriteContentToPngFile PNGFile
End With
End Sub
Private Sub Form_Terminate()
New_c.CleanupRichClientDll
End Sub
Here's a preview of the green-circle after conversion (from one of those EMZs, which were created during HTML-export).

Olaf
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|