Search Results for "Craig Vallee"

Convert Multi-page image to Collection of Bitmaps

Recently on a project, we had the need to convert a saved multi-page tiff to a collection of bitmaps for viewing in a UI using standard GDI+ methods. These bitmaps also needed to be printed in a high quality way for submission to a government agency.  This method ensures that no quality will be lost from the creation of the new bitmap objects.
/////////////////////////////////////////
// by Craig Vallee
// Consultant
// Tallan, Inc.
/////////////////////////////////////////

private static List<Bitmap> ImageToBitmap()
{
//Create and Image object from file path and name
Image originalImage = Image.FromFile(@”C:\Temp\Your_File.tif”);

//Create a collection of Bitmap objects
List<Bitmap> bitmapList = new List<Bitmap>();

//Place holders for setting resolution of new Bitmap objects
var xResolution = originalImage.HorizontalResolution;
var yResolution = originalImage.VerticalResolution;

//Create FrameDimesion…

Modularizing .NET Training Part 1

A challenge we have at Tallan is keeping our training up-to-date with the latest and greatest of technologies. We are constantly re-evaluating our lessons to keep up with ever changing technologies. In recent months, we have seen a shift in our client work from using traditional ASP.NET to using ASP.NET MVC 2. This has challenged our .NET developers to learn and create MVC best practices and ensure high quality deliverables. As you may know, MVC to a .NET developer can take time to understand and learn.
As an organization, we approach training from a mentor/mentee concept. This allows our trainees to have a dedicated training partner to guide him/her through the module and it allows for the mentor to learn communication and management skills. We have begun reviewing our training process, in particular our .Net training modules. With this in mind…

Using Atalasoft DotImage to create blank Tiff image

Atalasoft DotImage is a great library for working with all kinds of images. I recently had the need for a Tiff image which met the following specification:

300 x 300 dpi
Print at regular letter size (8 1/2 x 11)
Encoded using Group 4 compression

I created this Tiff file using only the following 5 lines of code:
Prior to using this code I had simply scanned a blank sheet. I quickly realized this was not a good alternative due to inconsistencies with the scanner bed. Using this simple code I created a perfect Tiff.
-Craig

Learning WPF

As a .net developer that has recently spent over a year helping to design and build a SCSF winforms application, I have been looking to branch out into different techniques and technologies to improve my skill set.  With Visual Studio 2010 coming out, the latest support for WPF and a push, by Microsoft, toward its advancement in the development community, I am intrigued to say the least to check it out. I do not consider myself a UI designer, and lack the artistic skills to become one, so learning WPF seems like a daunting task.
I did find the following website to help with my desire to learn WPF: www.wpftutorial.net. There is a great Getting Started section which will get you on your way to understanding the basics. From learning XAML and basic MVVM concepts, the tutorial is presented in an…

Handle asp.net MVC session expiration

Here is a really simple way to handle a session expiration in asp.net MVC using a base controller.  Having all controller inherit from a basecontoller and overriding the OnActionExecuting event allows for checking the session before all actions are executed.
Here is the code
public class BaseController : Controller

{

protected override void OnActionExecuting

(ActionExecutingContext filterContext)

{

// If session exists

if (filterContext.HttpContext.Session != null)

{

//if new session

if (filterContext.HttpContext.Session.IsNewSession)

{

Transform System.Drawing.ContentAlignment property to System.Drawing. StringFormat Alignment property

Recently we had the need to transform System.Drawing.ContentAlignment property to System.Drawing. Stringformat alignment property for creating a Graphic object with text drawn on it inside a given rectangle.  Assuming that you want the text printed from left to right, you can use the ContentAlignment Enum values to obtain the desired StringAlignment Enum value.  For example:

1: public StringFormat TransformProperty(ContentAlignment alignment)

2: {

3: StringFormat myStringFromat = new StringFormat();

4: switch(alignment)

5: {

6: …

Adding SQLite to a Windows Mobile Application

Using SQLite in a Windows Mobile Application provides a simple way to add pre-populated data for consumption by the application.  There are a couple of configuration considerations when adding the database to the project.
1. Adding reference to SQLite.dll. After installing SQLite there will be a Compact Framework folder in the following path :C:\ProgramFiles\SQLite.NET\bin.  This folder contains the System.Data.SQLite.dll that needs to be referenced.
2 The same path will also contain the dll which Windows Mobile will need to invoke the methods contained in the SQLite.dll.  The following file needs to be added to the project which contains the main executable,  SQLite.Interop.065.DLL.
Once the interop dll is in the project you can start using SQLite in the Mobile Application just as you would for any other application.
Craig

WCF Exception Shielding Error

While using the WCF Exception Shielding policy in Enterprise Library’s Exception Handler Block to shield exceptions and return Fault Contracts I came across an error. I named the shielding policy “WCF Shielding Policy” and implemented a FaultContract for each type of desired or expected exception.
While testing the policy, we were unable to return a proper FaultContract from the WCF Service.  The only error that we received was the generic Communication Error:
System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to (path of service).
This could be due to the service endpoint binding not using the HTTP protocol.
This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down).
See server logs for more details. —> System.Net.WebException: The underlying connection was closed:
An unexpected error occurred on a receive.
System.IO.IOException: Unable…

Spring and Functional Tests

Recently on our project we created a “functional” unit test for some services. The test was designed to check the entire call stack from the service layer to the DAO and return some expected results. We are using Spring for dependency injection through our entire application. This functional test initially only referenced the service DLL’s as this is all we thought that had to be referenced.  Upon execution, the test was failing due to “null or empty Context”. We knew that we had referenced the context in the configuration file correctly, but were perplexed at how the spring context were not loading.
We finally realized that it was an issue with Resharper and how the tests were executed differently then when run is Visual Studio using default run (ctrl + r, t)
Once this was solved, we were getting reference exceptions.
To solve…

Bitmap Default resolution

Recently I encountered a problem regarding default resolution for Images. An image that had been stored in a database as a multi-page tiff needed to be split into individual bitmaps for display and print on a winform using standard GDI+. While spliting the tiffs and creating the new bitmaps, the resolution was lost and was set to the default value of Bitmaps. While the display on the winform was not a problem as the viewer handled the image sizing, the printing of the image resulted in a very distorted printed image.
Upon examination of the image, the resolution was 300 x 300. Upon creation of the bitmap it defaulted to 72 x 72.
This problem was quickly resolved by setting the resolution of all of the new  bitmaps  to the original resolution contained in the image object.
Seems like a simple fix, but…

\\\