Blog posts about morgan

  • Watermarking the easy way

    March 01, 2010 | Tags: Morgan, Image Library, C#, Snippet
    This post will show how easy it is to do a bit of watermarking using the open source C# Image Library.

    What we'll do
    Watermarks can appear in many different ways. This sample will show how to create the following in just a couple of lines:

    (Image above courtesy of Morgan over at Imaginations. Check out his site for some beautiful CG imagery.)

    Step by step

    First of all, head over to and download the latest DLL (or source code if you want to compile it yourself).

    Secondly, you'll need a watermark to apply to your images. Create a PNG image with very transparent layers in both black and white. The one I've created has black texts in a layer of 10% opacity as well as a white outline also with 10% opacity. (Please note that the watermark will be tiled, in other words used x * y times to cover the image you want to mark.)
    This is my watermark.png (applied on a gray background):

    Finally lets do some coding!
     Create a new project and add the C# Image library  you just downloaded (either the DLL or the project). Enter the following lines (in the appropriate place, depending of what type of project you're developing).
    using Kaliko.ImageLibrary;


    // Open the image you want to watermark
    KalikoImage image = new KalikoImage("c:\\MyImage.jpg");

    // Apply your watermark PNG image

    // Save new marked image as high-quality jpeg
    image.SaveJPG("c:\\Marked.jpg", 99);

    That wasn't so hard, was it? :) The C# Image library is developed to ease common graphical tasks as this.

    Bookmark and Share

  • Get correct week number in .NET

    November 20, 2009 | Tags: Morgan, ASP.NET, C#, Snippet
    A nice piece of code submitted by Morgan Johansson for getting the correct week number for your region (in this sample code Sweden ("se-SE"):
    public int GetWeekNo(DateTime date) {
    System.Globalization.CultureInfo cult_info = System.Globalization.CultureInfo.CreateSpecificCulture("se-SE");
    System.Globalization.Calendar cal = cult_info.Calendar;
    int weekNo = cal.GetWeekOfYear(date, cult_info.DateTimeFormat.CalendarWeekRule, cult_info.DateTimeFormat.FirstDayOfWeek);
    return weekNo;