As I said before, I solved the problem of adding a header to an image but now I'm facing another problem. In this case the problem is related to the size of the new image (with the header). The new one is almost 3 times the original size.
This an image example (original and with header), 87kb vs 231kb:
http://img21.imageshack.us/my.php?image=imagenpy.jpg
http://img21.imageshack.us/my.php?image=imagewithheader.jpg
This is the code I use:
---------------------------------------------------------------------------
RasterCodecs.Startup();
RasterCodecs codecs = new RasterCodecs();
RasterImage imagenOriginal = codecs.Load("C:\\image.jpg");
RasterImage imagenNueva = new RasterImage(RasterMemoryFlags.Conventional, imagenOriginal.Width, imagenOriginal.Height + 50, imagenOriginal.BitsPerPixel, RasterByteOrder.Bgr, imagenOriginal.ViewPerspective, null, IntPtr.Zero, 0);
//Important Note: If image is 8-bits or less, you must copy palette from imagenOriginal to imagenNueva
FillCommand cmdFill = new FillCommand(RasterColor.FromGdiPlusColor(Color.Black));
cmdFill.Run(imagenNueva);
CombineFastCommand cmdCombine = new CombineFastCommand(imagenNueva, new Rectangle(0, 50, imagenOriginal.Width, imagenOriginal.Height), new Point(0, 0), CombineFastCommandFlags.OperationAdd);
cmdCombine.Run(imagenOriginal);
RasterImageGdiPlusGraphicsContainer container = imagenNueva.CreateGdiPlusGraphics();
container.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
Font fuente = new Font("Arial", 14, GraphicsUnit.Pixel);
StringBuilder sbLineaCabecera = new StringBuilder();
sbLineaCabecera.AppendLine(TimeStamp.ToString("dd/MM/yyyy") + " some text");
sbLineaCabecera.Append(TimeStamp.ToString("HH:mm:ss.fff"));
int x = 10;
int y = 5;
container.Graphics.DrawString(sbLineaCabecera.ToString(), fuente, new SolidBrush(Color.White), x, y);
codecs.Save(imagenNueva, "C:\\image_with_header.jpg", RasterImageFormat.Jpeg, imagenOriginal.BitsPerPixel, 1, 1, 1, CodecsSavePageMode.Overwrite);
RasterCodecs.Shutdown();
---------------------------------------------------------------------------