Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 711325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:43:21+00:00 2026-05-14T04:43:21+00:00

Currently I have a third party control that generates a Metafile. I can save

  • 0

Currently I have a third party control that generates a Metafile. I can save the .wmf file to disk with out issue. The problem is how do I render the Metafile as a Tiff file.

Currently I have the following code to get my metafile and save it.

 Dim mf As Metafile = page.GetImage(TXTextControl.Page.PageContent.All)



                        Dim enhMetafileHandle As IntPtr = mf.GetHenhmetafile()

                        Dim h As IntPtr
                        Dim bufferSize As UInteger = GetEnhMetaFileBits(enhMetafileHandle, 0, h)
                        Dim buffer(CInt(bufferSize)) As Byte

                        GetEnhMetaFileBits(enhMetafileHandle, bufferSize, buffer)

                        Dim msMetafileStream As New MemoryStream
                        msMetafileStream.Write(buffer, 0, CInt(bufferSize))


                        Dim baMetafileData() As Byte
                        baMetafileData = msMetafileStream.ToArray
                        Dim g As Graphics = Graphics.FromImage(mf)


                        mf.Dispose()



                        File.WriteAllBytes("c:\a.wmf", baMetafileData)

end sub

_
Public Shared Function GetEnhMetaFileBits( ByVal hEMF As System.IntPtr, ByVal nSize As UInteger, ByVal lpData As IntPtr) As UInteger
End Function

<System.Runtime.InteropServices.DllImportAttribute("gdi32.dll", EntryPoint:="GetEnhMetaFileBits")> _

Public Shared Function GetEnhMetaFileBits(<System.Runtime.InteropServices.InAttribute()> ByVal hEMF As System.IntPtr, ByVal nSize As UInteger, ByVal lpData() As Byte) As UInteger
End Function

I’ve tried all sort of IMAGE and Graphic calls and just can’t save the meta file as a .tiff. Any suggestions would be great. I even tried to create a new bitmap and draw the metafile onto it. I always end up with a GDI exception being thrown.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:43:21+00:00Added an answer on May 14, 2026 at 4:43 am

    My final Code Looks like:

     Dim NewGraphic As Graphics = Nothing
            Dim BitonalImage As Bitmap = Nothing
    
            Using bmp As New Bitmap(3264, 4224)
                Try
    
                    NewGraphic = Graphics.FromImage(bmp)
                    NewGraphic.FillRectangle(New SolidBrush(Color.White), 0, 0, 3264, 4224)
                    NewGraphic.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                    NewGraphic.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
                    NewGraphic.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
                    NewGraphic.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
                    NewGraphic.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit
    
                    NewGraphic.DrawImage(MetaFileToConvert, 0, 0, 3264, 4224)
    
                    BitonalImage = CType(ConvertToBitonal(CType(bmp, Bitmap)), Bitmap)
                    BitonalImage.SetResolution(385, 385)
    
                    OutBMP = BitonalImage
    
                Catch ex As Exception
                    Throw ex
                Finally
                    NewGraphic.Dispose()
                    BitonalImage.Dispose()
                End Try
    
            End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a Windows Forms application that uses a (third party) ActiveX control, and
I have an MFC application that uses an ancient (circa 1999) third-party ActiveX control.
Is there a replacement technology for TAPI that supports third-party call control (3pcc)? I
I currently have implemented a third party library into my XCode project. The problem
Currently have a drop down menu that is activated on a hover (from display:none
I currently have a XSLT 2.0 Stylesheet that I am trying to remove empty
I currently have one project that currently contains multiple packages. These packages make up
I currently have a deployed app (fortworth.herokuapp.com) that I am attempting to sort movies
I have an ASP.NET 2.0 page with many repeating blocks, including a third-party server-side
i am looking to extend a third party control, it is a ComboBox (so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.