Friday, March 06, 2009
prelude to a screen cap
<%@ Page Language="VB" Debug="True" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%
' Declare Vars
Dim objBMP As System.Drawing.Bitmap
Dim objGraphics As System.Drawing.Graphics
Dim objFont As System.Drawing.Font
' Create new image - bitmap
objBMP = New Bitmap(100, 30)
' Create a graphics object to work with from the BMP
objGraphics = System.Drawing.Graphics.FromImage(objBMP)
' Fill the image with background color
objGraphics.Clear(Color.Green)
' Set anti-aliasing for text to make it better looking
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias
' Configure font to use for text
objFont = New Font("Arial", 16, FontStyle.Bold)
' Write out the text
objGraphics.DrawString("ASP 101", objFont, Brushes.White, 3, 3)
' Set the content type and return the image
Response.ContentType = "image/GIF"
objBMP.Save(Response.OutputStream, ImageFormat.Gif)
' Kill our objects
objFont.Dispose()
objGraphics.Dispose()
objBMP.Dispose()
%>
as c#
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%
//' Declare Vars
System.Drawing.Bitmap objBMP;
System.Drawing.Graphics objGraphics;
System.Drawing.Font objFont;
//' Create new image - bitmap
objBMP = new Bitmap(100, 30);
//' Create a graphics object to work with from the BMP
objGraphics = System.Drawing.Graphics.FromImage(objBMP);
//' Fill the image with background color
objGraphics.Clear(Color.Green);
//' Set anti-aliasing for text to make it better looking
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
//' Configure font to use for text
objFont = new Font("Arial", 16, FontStyle.Bold);
//' Write out the text
objGraphics.DrawString("ASP C#", objFont, Brushes.White, 3, 3);
//' Set the content type and return the image
Response.ContentType = "image/GIF";
objBMP.Save(Response.OutputStream, ImageFormat.Gif);
//' Kill our objects
objFont.Dispose();
objGraphics.Dispose();
objBMP.Dispose();
%>
Thursday, March 05, 2009
screen capping
i want my little cassini web server to take a screen cap of the it is running on.
should be easy shouldnt it? shouldnt it?
Well I found this nice example from the code project:
http://www.codeproject.com/KB/cpp/Screen_Capture__Win32_.aspx
should be easy shouldnt it? shouldnt it?
Well I found this nice example from the code project:
http://www.codeproject.com/KB/cpp/Screen_Capture__Win32_.aspx
WCHAR buf [100],buf1[20];
int xSrc=0,ySrc=-19;
int DepcWidth=10, DepcHeight=5;
OutputDebugString(L"Start capture act window ");
HDC ActWndDC = GetDC(hWndActWnd); //DC for the window you have clicked on
MemDC = CreateCompatibleDC(ActWndDC); //Memory DC Compatible with Above DC
GetWindowRect(hWndActWnd,&ActWndRect); //Will Store the Windows Are in Rectangle
wsprintf(buf,L"x1 = %d , y1 = %d, x2 = %d y2 =%d",ActWndRect.left,ActWndRect.top,ActWndRect.right,ActWndRect.bottom);
OutputDebugString(buf);
int Width = ActWndRect.right-ActWndRect.left; //Width of the Window
int Height =ActWndRect.bottom-ActWndRect.top; //Hight of the Window
if(GetWindowText(hWndActWnd,buf1,20) >0)
{
OutputDebugString(buf1);
}
if(CaptureControl)
{
ySrc= DepcWidth = DepcHeight = 0;
}
HBITMAP hBitmap = CreateCompatibleBitmap(DlgDC,Width-DepcWidth,Height-DepcHeight);//Will Create Bitmap Comatible With Our Window
SelectObject(MemDC,hBitmap);
BitBlt(MemDC,0,0,Width,Height,ActWndDC,xSrc,ySrc,SRCCOPY);//Will Copy the Window into MemDC
//BitBlt(DeskDC,110,110,Width,Height,MemDC,Begpt.x,Begpt.y,SRCCOPY);
SaveBitmap(MemDC, hBitmap,"Sample.bmp"); // will Save DC into .bmp File
ShowImage(); //Will Show u the .bmp File in MSPAINT.
getting cassini to work
I farted around with cassini last week but i couldnt get the thing to build and to install the assemble into the gac.
i found a trick from another project i was working on.
start the command compiler command shell with the visual studio tools
cd to the cassini director and run build.bat
i was able to build and install cassini
i created a simple web project a blank page and moved this to the director c:\temp
and ran
C:\Cassini>CassiniWebServer.exe c:\temp 8080 /temp
loaded mozilla and
ran
http://localhost:8080/temp/
i found a trick from another project i was working on.
start the command compiler command shell with the visual studio tools
cd to the cassini director and run build.bat
i was able to build and install cassini
i created a simple web project a blank page and moved this to the director c:\temp
and ran
C:\Cassini>CassiniWebServer.exe c:\temp 8080 /temp
loaded mozilla and
ran
http://localhost:8080/temp/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>
Untitled Page
</title></head>
<body>
<form name="form1" method="post" action="default.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGSLYl3aThqDqzWeHM/cMb5uC4Vx5A==" />
</div>
<div>
</div>
</form>
</body>
</html>
Sunday, March 01, 2009
Interfaces
namespace myspace
{
interface ifoo
{
public void bar();
}
class Iamfoo : public ifoo //this would fail because its not c++
{
public void bar()
{
}
};
}
{
interface ifoo
{
public void bar();
}
class Iamfoo : public ifoo //this would fail because its not c++
{
public void bar()
{
}
};
}