Search Results

Search found 2 results on 1 pages for 'pehaada'.

Page 1/1 | 1 

  • VB.net Saving an MetaFile / EMF as a bitmap ( .tiff)

    - by pehaada
    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.

    Read the article

  • Stored Connection Strings per user

    - by pehaada
    In the past I've used a Singleton Pattern to load the connection string when the application starts via the global.asa file. I have a project now where each user has a unique connection string to the database. I would like to load this connection string once. The issue is that the singleton pattern will not work for me since each user has there own connection string. Basically the connection string is created dynamically. I do not want to store it is session. If anyway has a clever way of doing this in .NET let me know ?

    Read the article

1