Friday, May 6, 2011
How to programmatically create a deep zoom composition on the fly?
--------------------------------------------------------------------------------------------------------------------
protected void Button1_Click(object sender, EventArgs e)
{
ImageCreator creator = new ImageCreator();
creator.TileFormat = ImageFormat.Jpg;
creator.TileOverlap = 1;
creator.TileSize = 256;
List<string> files = new List<string>()
{
@"C:\Users\Public\Pictures\Sample Pictures\Toco Toucan.jpg",
@"C:\Users\Public\Pictures\Sample Pictures\Winter Leaves.jpg",
@"C:\Users\Public\Pictures\Sample Pictures\Humpback Whale.jpg"
};
string root = @"C:\Users\XXXX\Desktop\mytest\MyGeneratedImages";
List<string> dzi = new List<string>();
foreach (var name in files)
{
string output = Path.Combine(root, Path.GetFileNameWithoutExtension(name) + ".dzi");
dzi.Add(output);
creator.Create(name, output);
}
CollectionCreator ccreator = new CollectionCreator();
ccreator.TileFormat = ImageFormat.Jpg;
ccreator.TileOverlap = 1;
ccreator.TileSize = 256;
ccreator.Create(dzi, Path.Combine(root, "da.dzc"));
}
Thursday, May 5, 2011
How to overlap an image or text on another image using css? (Div overlapping, Div absolute, relative position)
<img src="../images/MyImage.jpg" />
<div style="text-align: center; right:10px; position:absolute">
Overlapped Text
</div>
</div>
In the above example, the outer Div is styled to align relatively to the parent control, and the inner div is styled to align in absolute position with respective to the parent Div.
Saturday, March 5, 2011
Things to remember when implementing WebFarm
data is stored as part of the Application Domain
2. Make sure you use the OutProc mode to store the session data
3. Be aware that session_OnEnd event of the HttpApplication object will not
fire when OutProc mode is used
4. Make sure that all the clusters in the webfarm use the same value for
ValidationKey attribute of the MachineKey element in the configuration
How to save the picture captured from webcam in Silverlight? Saving captured images in Silverlight. ImageTools.
1) Just go to http://imagetools.codeplex.com/ and download ImageTools.
2) Add reference to ImageTools
3) Add reference to ImageTools.Utils
4) Add reference to ImageTools.IO.<preferred file format>
The Code
-------------------------
If the requirement is to save the captured image to local machine
void source_CaptureImageCompleted(object sender, CaptureImageCompletedEventArgs e)
{
if (e.Result != null)
{
//CapturedImage is an Image control
CapturedImage.Source = e.Result;
//Cannot directly call 'showDialog' here. Dialog must be user-initiated.
}
}
private void SavePicture_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog { DefaultExt = ".png", Filter = "PNG Files (*.png)*.pngAll Files (*.*)*.*", FilterIndex = 1 };
bool? dialogResult = saveFileDialog.ShowDialog();
if (dialogResult.HasValue && dialogResult.Value)
{
var image = CapturedImage.ToImage(); //ToImage is an Extension Method, which returns an ExtendedImage
var encoder = new PngEncoder();
using (Stream stream = saveFileDialog.OpenFile())
{
encoder.Encode(image, stream);
stream.Close();
}
}
}
-----------------------------------------------------------
If the requirement is to send the image as byte stream to a service
using (Stream stream = saveFileDialog.OpenFile())
{
byte[] bytes = null;
stream.Write(bytes, 0, bytes.Length);
//Pass the bytes to the sevice
stream.Close();
}

Friday, February 25, 2011
How to use a Windows Forms Class Libary in Asp.Net
1. Create a new Windows Forms Control Library Project
2. Add reference to any dependent controls (Com components or activeX controls)
3. Design control according to the requirement
4. Select 'Make assembly COM Visible' under 'Properties of the project > Application > Assembly Information'.
5. Add "c:\windows\Microsoft.NET\framework\v4.0.30319\regAsm.exe /u <TheTargetDll.dll>" Under Build Events > Pre build event command line
6. Add "c:\windows\Microsoft.NET\framework\v4.0.30319\regAsm.exe <TheTargetDll.dll>" Under Build Events > Post build event command line
7. Select 'Register for COM interop' under Build > Output
8. Sign the assembly if you are planning to install the assembly in the GAC
2. Place the following code in the webpage.
<object ID="MyId" classid="Paste the class id"/>
Wednesday, July 14, 2010
How to resolve the "The document was understood, but it could not be processed." error occurred while Adding Service Reference to a WCF Service hosted on a Vista machine?
------------------------------
go to - Start > Run
type - %windir%
locate the 'Temp' folder
open properties of the 'Temp' folder
select 'Security' tab
click 'Advanced' button
click 'Edit'
select 'Network Service' and click 'Edit'
check 'List folder / read data'
check 'Create files / write data'
and click 'Ok'
Now try adding a Service Reference to the WCF Service.
Worked for me.
