0

I am trying to draw some string to bitmap at certain position and copy a barcode bitmap to the new bitmap.I have not done with graphics before so i don't know where to start.

Can anyone guide me on this?my output of the bitmap is a receipt like.

1
  • Hi, please check the answer below. Commented Jul 23, 2015 at 12:23

1 Answer 1

1

Here is a solution. Please make a grid or canvas and put the barcode image and use a label with desired text and put the label on desired location relative to barcode grid. So, trick is you can immediately take screenshot of this grid using following code.Then, you are done.

public void ConvertToBitmapSource(UIElement element)
{
    var target = new RenderTargetBitmap(
        (int)element.RenderSize.Width, (int)element.RenderSize.Height,
        96, 96, PixelFormats.Pbgra32);
    target.Render(element);

    var encoder = new PngBitmapEncoder();
    var outputFrame = BitmapFrame.Create(target);
    encoder.Frames.Add(outputFrame);

    using (var file = File.OpenWrite("TestImage.png"))
    {
        encoder.Save(file);
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.