Click here to Skip to main content
13,458,750 members
Click here to Skip to main content
Add your own
alternative version


38 bookmarked
Posted 31 May 2008

Image, Icon, Cursor, and Anything Else to Base-64 Converter Utility

, 11 Sep 2008
Rate this:
Please Sign up or sign in to vote.
A simple utility which provides a GUI to converte images to base-64 strings



During a recent project I found myself needing to convert several bitmap images to base-64. I couldn't find a simple tool to achieve this, so I created this very simple utility to facilitate my task. So whilst this article only presents some basic information, its purpose is simply to assist those who could benefit from such a utility.

The latest version of this utility now supports images, icons, cursors, along with any other data file. The new version provides the following functions:

  • string FileToBase64String(string path) - Refer to ImageFromBase64String as a guide to reverse procedure.
  • string ImageToBase64String(Image image, ImageFormat format)
  • string IconToBase64String(Icon image)
  • Image ImageFromBase64String(string base64)
  • Icon IconFromBase64String(string base64)
  • Cursor CursorFromBase64String(string base64)


Images can be stored either externally to your application or internally within some form of resource file. However, sometimes it is useful to store a string representation of an image. For example, when binary transfer is not an option, or if an image is to be stored directly within source code.

Using the Code

Whilst the tool is fairly self contained I thought it would be useful to explain how this utility converts from an image to base-64, and likewise how to convert back again.

Convert from an Image to a base-64 string

public string ImageToBase64String(Image image, ImageFormat format)
   MemoryStream memory = new MemoryStream();
   image.Save(memory, format);
   string base64 = Convert.ToBase64String(memory.ToArray());

   return base64;

Convert from a base-64 string to an Image

public Image ImageFromBase64String(string base64)
   MemoryStream memory = new MemoryStream(Convert.FromBase64String(base64));
   Image result = Image.FromStream(memory);

   return result;



  • 31st May, 2008: Initial post
  • 11th Sept, 2008: updated version contains specific support for images, icons, and cursors, but it can now also convert any file to base-64


This article, along with any associated source code and files, is licensed under The MIT License


About the Author

Lea Hayes
Software Developer Rotorz Limited
United Kingdom United Kingdom
I have been fascinated by software and video games since a young age when I was given my first computer, a Dragon 32. Since then I have experimented with numerous methods of development ranging from point-and-click type packages to C++. I soon realized that software development was what I wanted to do.

Having invested a lot of time into programming with various languages and technologies I now find it quite easy to pickup new ideas and methodologies. I relish learning new ideas and concepts.

Throughout my life I have dabbled in game and engine development. I was awarded a first for the degree "BEng Games and Entertainment Systems Software Engineering" at the University of Greenwich. It was good to finally experience video games from a more professional perspective.

Due to various family difficulties I was unable to immediately pursue any sort of software development career. This didn't stop me from dabbling though!

Since then I formed a company to focus upon client projects. Up until now the company has primarily dealt with website design and development. I have since decided that it would be fun to go back to my roots and develop games and tools that other developers can use for their games.

We have recently released our first game on iPhone/iPad called "Munchy Bunny!" (see:!/id516575993?mt=8). We hope to expand the game and release to additional platforms.

Also, check out our tile system extension for Unity! (see:

You may also be interested in...

Comments and Discussions

QuestionI cannot execute the app Pin
linfengtingyu18932323224-Jun-13 4:25
memberlinfengtingyu18932323224-Jun-13 4:25 
QuestionHow to download Pin
kobsev22-Jun-09 19:35
memberkobsev22-Jun-09 19:35 
AnswerRe: How to download Pin
lhayes0023-Jun-09 2:36
memberlhayes0023-Jun-09 2:36 
GeneralNifty little tool [modified] Pin
wwwastrel18-Mar-09 23:01
memberwwwastrel18-Mar-09 23:01 
GeneralRe: Nifty little tool Pin
lhayes0019-Mar-09 9:59
memberlhayes0019-Mar-09 9:59 
GeneralRe: Nifty little tool Pin
wwwastrel19-Mar-09 12:59
memberwwwastrel19-Mar-09 12:59 
Generalxml Pin
Vakond Jeno24-Sep-08 4:52
memberVakond Jeno24-Sep-08 4:52 
GeneralRe: xml Pin
lhayes0024-Sep-08 16:04
memberlhayes0024-Sep-08 16:04 
GeneralA problem ! Pin
Mohammad Dayyan15-Sep-08 10:58
memberMohammad Dayyan15-Sep-08 10:58 
GeneralRe: A problem ! Pin
lhayes0015-Sep-08 11:03
memberlhayes0015-Sep-08 11:03 
GeneralRe: A problem ! [modified] Pin
Mohammad Dayyan15-Sep-08 11:17
memberMohammad Dayyan15-Sep-08 11:17 
GeneralRe: A problem ! Pin
lhayes0016-Sep-08 22:47
memberlhayes0016-Sep-08 22:47 
GeneralRe: A problem ! Pin
Mohammad Dayyan17-Sep-08 2:01
memberMohammad Dayyan17-Sep-08 2:01 
GeneralRe: A problem ! Pin
lhayes0017-Sep-08 2:11
memberlhayes0017-Sep-08 2:11 
GeneralRe: A problem ! Pin
Mohammad Dayyan17-Sep-08 2:17
memberMohammad Dayyan17-Sep-08 2:17 
GeneralExcellent work Pin
Mohammad Dayyan12-Sep-08 3:22
memberMohammad Dayyan12-Sep-08 3:22 
GeneralThank you , but : Pin
Mohammad Dayyan9-Sep-08 12:50
memberMohammad Dayyan9-Sep-08 12:50 
GeneralRe: Thank you , but : Pin
lhayes009-Sep-08 12:54
memberlhayes009-Sep-08 12:54 
GeneralRe: Thank you , but : Pin
Mohammad Dayyan9-Sep-08 13:01
memberMohammad Dayyan9-Sep-08 13:01 
GeneralRe: Thank you , but : Pin
lhayes009-Sep-08 15:13
memberlhayes009-Sep-08 15:13 
GeneralRe: Thank you , but : Pin
Mohammad Dayyan9-Sep-08 15:21
memberMohammad Dayyan9-Sep-08 15:21 
GeneralRe: Thank you , but : Pin
lhayes0010-Sep-08 0:31
memberlhayes0010-Sep-08 0:31 
GeneralRe: Thank you , but : Pin
Mohammad Dayyan10-Sep-08 0:37
memberMohammad Dayyan10-Sep-08 0:37 
GeneralYeah! Thanks Pin
conrad Braam31-May-08 22:18
memberconrad Braam31-May-08 22:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01-2016 | 2.8.180323.1 | Last Updated 11 Sep 2008
Article Copyright 2008 by Lea Hayes
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid