Displaying multi-page tiff files using the ImageBox control and C#
A brief article showing how to display individual pages from a multi-page tiff file in the ImageBox control.
Today we've released a new updated version of the ImageBox
control, with a nice collection of enhancements and a few bug
fixes.
Full change log for this update:
ImageBox
control is licensed under the MIT
license, allowing you free reign to use it in your projects,
commercial or otherwise. See imagebox-license.txt
for the
full text.SizeMode
property. This allows you to switch
between Normal
, Fit
and Stretch
modes. Stretch is a new
mode for the ImageBox
, and acts similar to existing Fit
functionality except the aspect ratio is not preserved.SizeToFit
property has been marked as deprecated and
should no longer be used. The SizeMode
property has a Fit
value that should be used instead. Setting the SizeToFit
property will now manipulate SizeMode
instead.CenterPoint
property. This property returns the
pixel at the center of the current image viewport.Rectangle
, Point
or Size
to also accept float
and
int
arguments.Zoomed
event that uses new
ImageBoxZoomEventArgs
arguments. This new event allows you
to tell if the zoom was in or out, how it was raised, and
current and previous zoom values. Not hugely thrilled with how
aspects of this change has been internally implemented, so
implementation methods are private rather than virtual so I
can change them without affecting the signature.CenterToImage
method which resets the viewport to
be centered of the image, in the same way as zooming via the
keyboard used to work.Text
and Font
properties are now available and, if
set, will be displayed in the control. You can use the
ForeColor
, TextBackColor
, TextAlign
, TextDisplayMode
and ScaleText
properties to determine how the text will be
rendered.DrawLabel
method that performs text drawing is
available for use by custom implementations or virtual modes.ImageBox
.Zooming in and out with the keyboard now keeps the view centered to the same pixel that was centered prior to the zoom
Zooming in and out with the keyboard is now correctly disabled
if the AllowZoom
property is False
, or the SizeMode
property is a value other than Normal
. This means keyboard
behaviour now matches mouse behaviour.
If the mouse wheel was rapidly spun (thus having a multiple of
the base delta), the Zoom
property was only adjusted once
Setting the GridScale
property to None
rendered the
default Small
grid. Using a scale of None
now correctly
just fills the grid area with a solid brush from the
GridColor
property.
The MouseWheel
event is now available
Layout changes no longer occur if the AllowPainting
property
is false
through use of the BeginUpdate
method.
Fixed various documentation errors
As usual, either grab the source from GitHub, from the link below, or make use of the NuGet package!
Like what you're reading? Perhaps you like to buy us a coffee?
# Richard R.
# Richard Moss
# Richard R.
# Richard Moss
# Richard R
# Ravi Bhavnani
# Richard Moss
# Misiu
# Richard Moss
# Misiu
# Richard Moss
# Misiu
# Richard Moss
# Dave Gordon
# Richard Moss
# schorges
# Richard Moss
# Essam Mohamed Zaki