HELP! Need to convert HTML Page To image

  • Thread starter Thread starter Chad A. Beckner
  • Start date Start date
C

Chad A. Beckner

Hey all,

I know this has been done using C++ (I have one with source code), but I
don't know C++ that well. Does anyone know of a C++ to C# converter? -
OR - does anyone know to to retrieve a web page as an image (not get an
image from a web page)? I need to do this for an application I am working
on (non-comercial) and can't seem to find any code or hints on how to do
this.

Thanks for any help!

Chad
 
Chad,

If you have C++ code, thats enough to use it in C#. Couple of ways to try
that

1. Use Dll import and try to get the access to function
2. Or register it as COM and add a reference to c# project
3. Or you can code as Unsafe c#
 
The problem is that I can't use the C++ implementation of it, I *must* have
a C# or VB .NET version of it (sorry).

Chad
 
Chad,

If you have source code available in C++, its better you convert exe to dll.

If you just have exe, and if it accepts command line arguments, you can
still launch it in hidden mode using Process class.
 
Hi Chad,

the only solution I have is to capture the Control of eg Internet Explorer
that display the web page and save it.. Here's a snibbit:

[DllImport("User32.DLL")]

public static extern IntPtr GetActiveWindow ( );

[DllImport("gdi32.dll")]

private static extern bool BitBlt(IntPtr hdcDest,int nXDest,int nYDest,int
nWidth,int nHeight,IntPtr hdcSrc,int nXSrc,int nYSrc,System.Int32 dwRop);

[DllImport("User32.dll")]

public extern static System.IntPtr GetDC(System.IntPtr hWnd);

[DllImport("User32.dll")]

public extern static int ReleaseDC(System.IntPtr hWnd, System.IntPtr hDC);
//modified to include hWnd

private void Capture()

{

IntPtr hWnd = GetActiveWindow();

Form frm = (Form)Form.FromHandle(hWnd);

if(frm != null)

{

Control c = frm.ActiveControl;

if(c != null)

{


System.IntPtr srcDC = GetDC(c.Handle);

Bitmap bm = new Bitmap(c.Width,c.Height);

Graphics g = Graphics.FromImage(bm);

System.IntPtr bmDC = g.GetHdc();


BitBlt(bmDC,0,0,bm.Width,bm.Height,srcDC,0,0,0x00CC0020 /*SRCCOPY*/);



ReleaseDC(c.Handle, srcDC);

g.ReleaseHdc(bmDC);

g.Dispose();

bm.Save([FILENAME]);

}

}

}



Regards,

Munir Husseini

iCOMcept GmbH

www.icomcept.com
 
Back
Top