Creating a image viewer window controll.
Posted
by Scott Chamberlain
on Stack Overflow
See other posts from Stack Overflow
or by Scott Chamberlain
Published on 2010-04-16T18:38:18Z
Indexed on
2010/04/16
18:43 UTC
Read the original article
Hit count: 173
I am learning GDI+ and I am trying to make a display window with scroll bars (so I can only see part of the image at a time and I can scroll around it). I have read through the basics of GDI+ from several books but I have not found any good tutorials online or in books available to me about doing more advanced things like this.
Any recommendations on guides or example code on how do do this?
Here is what I have so far
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (Label != null)
{
using (Bitmap drawnLabel = new Bitmap(Label.LabelHeight, Label.LableLength, System.Drawing.Imaging.PixelFormat.Format1bppIndexed))
using (Graphics drawBuffer = Graphics.FromImage(drawnLabel))
{
drawBuffer.ScaleTransform(_ImageScaleFactor, _ImageScaleFactor);
foreach (Epl2.IDrawableCommand cmd in Label.Collection)
{
cmd.Paint(drawBuffer);
}
drawBuffer.ResetTransform();
}
}
}
I would like to paint this in to a PictureBox
I have on the control and control what is shown by a VScrollBar
and HScrollBar
but I don't know how to do that step.
P.S. Label is a custom class that I have in my namespace, it is a object that represents a label you would print from a label printer.
© Stack Overflow or respective owner