This documentation is for the old version. Go to the latest Graphics Mill docs

Creating Imagery for Mobile Devices

Developing web applications compatible with mobile devices (based on WAP) is a rather popular task nowadays. Displays of the mobile devices typically have quite limited capabilies so a special image file format was developed for them. This format is called WBMP. It is very simple and supports only bitonal images. Despite of the fact that many modern mobile devices support popular web formats like GIF or JPEG, if you want to create a web application, which can be displayed on any mobile device, you should use WBMP. Graphics Mill for .NET allows to create WBMP images (unlike standard means provided by ASP.NET, GDI+ and some other products). This topic will demonstrate how to do it.

The main feature of the WBMP is that it is a monochrome (bitonal) image format. Usually you have to translate images from true-color (for example photos) to 1 bit images. Do it on the last step, before saving or sending the image to a mobile device. All the image processing must be done for the true-color image.

The code example below demonstrates how to prepare true-color image for mobile devices (resize to fit device screen and convert to 1 bit) and save it in the WBMP file format.

Source image:

Source image

Result image:

Result image

The code which produces this image:

Visual Basic
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim bitmap As New Bitmap(Server.MapPath("SourceImages/Flower.jpg"))
    'Resize to 80 pixels width 
    bitmap.Transforms.Resize(80, 0, InterpolationMode.MediumQuality)

    'Reduce colors to black-and-white
    bitmap.ColorManagement.ConvertToIndexed(1, ColorPaletteType.Bicolor, Nothing)

    'Specify that we are going to save to WBMP
    Dim encoderOptions As New WbmpEncoderOptions

    'Save image to file
    bitmap.Save(Server.MapPath("ResultImages/wap.wbmp"), encoderOptions)

    'Save image to response stream
    Response.AddHeader("Content-Disposition", "atachment; filename=wap.wbmp")
    bitmap.Save(Response.OutputStream, encoderOptions)
End Sub
private void Page_Load(object sender, System.EventArgs e)
    Bitmap bitmap = new Bitmap(Server.MapPath("SourceImages/Flower.jpg"));
    //Resize to 80 pixels width 
    bitmap.Transforms.Resize(80, 0, InterpolationMode.MediumQuality);

    //Reduce colors to black-and-white
    bitmap.ColorManagement.ConvertToIndexed(1, ColorPaletteType.Bicolor, null);

    //Specify that we are going to save to WBMP
    WbmpEncoderOptions encoderOptions = new WbmpEncoderOptions();

    //Save image to file
    bitmap.Save(Server.MapPath("ResultImages/wap.wbmp"), encoderOptions);

    //Save image to response stream
    Response.AddHeader("Content-Disposition", "atachment; filename=wap.wbmp");
    bitmap.Save(Response.OutputStream, encoderOptions);