ImageBox 1.1.4.0 update
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:
Changes and new features
- Added NuGet package
- Added a license file to hopefully cut down on questions about
usage. The
ImageBox
control is licensed under the MIT license, allowing you free reign to use it in your projects, commercial or otherwise. Seeimagebox-license.txt
for the full text. - Added a new
SizeMode
property. This allows you to switch betweenNormal
,Fit
andStretch
modes. Stretch is a new mode for theImageBox
, and acts similar to existingFit
functionality except the aspect ratio is not preserved. - The
SizeToFit
property has been marked as deprecated and should no longer be used. TheSizeMode
property has aFit
value that should be used instead. Setting theSizeToFit
property will now manipulateSizeMode
instead. - Added a new
CenterPoint
property. This property returns the pixel at the center of the current image viewport. - Added a bunch of missing XML comments documentation.
- Added new overloads for most methods that accepted a source
Rectangle
,Point
orSize
to also acceptfloat
andint
arguments. - Added a new
Zoomed
event that uses newImageBoxZoomEventArgs
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. - Added new
CenterToImage
method which resets the viewport to be centered of the image, in the same way as zooming via the keyboard used to work. - Added support for animated GIF's, thanks to a contribution from Eggy. Note animations only play at runtime, not design time.
- The
Text
andFont
properties are now available and, if set, will be displayed in the control. You can use theForeColor
,TextBackColor
,TextAlign
,TextDisplayMode
andScaleText
properties to determine how the text will be rendered. - A new
DrawLabel
method that performs text drawing is available for use by custom implementations or virtual modes.
Demonstration Changes
- Added a new Scaled Adornments demonstration, showing how easy it is to add custom drawing that is scaled and positioned appropriately.
- Added a new Switch Image During Zoom demonstration, a demo
with an unwieldy name that shows how to switch out a low
resolution image with a higher detailed one as you zoom into
an
ImageBox
. - Added new Text and Size Mode demonstrations.
Bug Fixes
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 isFalse
, or theSizeMode
property is a value other thanNormal
. 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 onceSetting the
GridScale
property toNone
rendered the defaultSmall
grid. Using a scale ofNone
now correctly just fills the grid area with a solid brush from theGridColor
property.The
MouseWheel
event is now availableLayout changes no longer occur if the
AllowPainting
property isfalse
through use of theBeginUpdate
method.Fixed various documentation errors
Downloads
As usual, either grab the source from GitHub, from the link below, or make use of the NuGet package!
Related articles you may be interested in
- Displaying multi-page tiff files using the ImageBox control and C#
- Adding drag handles to an ImageBox to allow resizing of selection regions
- ImageBox and TabList update's - virtual mode, pixel grid, bug fixes and more!
- ImageBox update, version 1.1.0.0
- Zooming to fit a region in a ScrollableControl
- Zooming into a fixed point on a ScrollableControl
- Arcade explosion generator
- Creating an image viewer in C# Part 5: Selecting part of an image
- Extending the ImageBox component to display the contents of a PDF file using C#
- Creating a scrollable and zoomable image viewer in C# Part 4
- Creating a scrollable and zoomable image viewer in C# Part 3
- Creating a scrollable and zoomable image viewer in C# Part 2
- Creating a scrollable and zoomable image viewer in C# Part 1
Downloads
Filename | Description | Version | Release Date | |
---|---|---|---|---|
Cyotek.Windows.Forms.ImageBox.zip
|
Cyotek ImageBox Control, 1.1.4.2 update |
1.1.4.2 | 13/02/2014 | Download |
Leave a Comment
While we appreciate comments from our users, please follow our posting guidelines. Have you tried the Cyotek Forums for support from Cyotek and the community?
Comments
Richard R.
#
How can I include the ImageBox class/control into my current solution (c# - WinForm) eliminating the need for the DLL dependency? I really want to find a way for this approach as distributing an additional DLL would be problematic.
Richard Moss
#
Hello,
Although the control has grown a bit (or a lot :)) beyond it's more humble beginnings, you can still just add all the files in the solution to your own project and go from there. You could probably exclude some files and delete code that you don't need. (For example the new Zoomed event, if you don't need it, delete it and drop the related event args class and support enum classes. I planned on adding conditional constants to the next update, but deleting code is just as easy!)
However, if you can I'd recommend you stick with a pre-built binary - the NuGet package will be updated with each new version. But, as you have the source you can embed it in your project and tweak it for your needs.
Hope this helps!
Regards; Richard Moss
Richard R.
#
Love the control! As for the question, I found that you need to get all the needed files into your own project. Compile it - fix - compile until there are no errors AND then use the toolbox feature to "Choose Items". Browse to the location of the EXE file your compile just created and select that file. ( This is just like if you had worked with a class lib and created a DLL :) ) Click on the add/ok button and the toolbox will find the control and add it to the toolbox. After that, adding it to my form and everything else went great! I expect that we will work with this control and be able to contribute back soon with new additions and improvements. This is a fantastic control! Thank You!
Richard Moss
#
Hello,
There ought not to be any compile errors, what problems did you have? In regards to the toolbox, I don't normally include it directly in the application source, but I do include it in a class library which is always added in source form to the project - Visual Studio automatically populates the toolbox with items in this scenario.
However, I'm glad you've got it embedded and are finding it useful. Good luck with your project!
Regards; Richard Moss
Richard R
#
No problems with ImageBox, just trying to make clear that you should have a clean compile before trying to add the control to the toolbox. For my particular project, I needed it embedded and the end result was great! Thanks again!
Ravi Bhavnani
#
First of all, thanks for an amazing control and a full-featured demo app!
Would it be possible to add the ability to resize the selection rectangle (a la the ye olde MFC CRectTracker)?
Thanks,
--Ravi B
Richard Moss
#
Ravi,
It is an idea which has crossed my mind a few times, but at the same time it's expanding functionality beyond just the displaying of images, which at the end of the day is what the control is for. Still, it is in the back of my mind as something which would be useful so sooner or later I'll add it (otherwise why did I add selection in the first place!), or someone else will contribute it :)
Regards; Richard Moss
Misiu
#
First of all this is awesome control and awesome API to convert pdf's into images. I'm right now creating application (university project) to open multiple files (document viewer) and I was searching for a way to display PDF's. Thanks to Your solution this is possible! I integrated Your code into my application in minutes. Everything works nice, I have just 2 tiny comments: 1. When loading pages inside Your demo app I noticed that whole application is freezing for a second. Do You think it would be possible to do that in separate thread? Show some kind of loading indicator and hide after everything get loaded? This way UI won't freeze. I'm building my project using .NET 4 so Tasks may be handy :) 2. Second thing is mouse zooming, right now is is zooming to top left corner, could that be changed to zoom to mouse position? If I need to read informations that are in bottom-right corner and I zoom in I must use scrollbars to scroll to that place. I suppose that I could point mouse there and using wheel zoom to that region. Maybe this is configurable, but I didn't found it yet.
Ones more thanks for this great code and best wishes.
Richard Moss
#
Hello,
Thanks for your comments, I'm glad you're finding the code useful.
In regards to your first comment - I assume you're talking about another article on this site which describes how to use the ImageBox + GhostScript in order to display PDF's? It should be perfectly possibly to get a Task to do this work, just modify the code that calls the PDF conversion. Not the most helpful answer but off the top of my head I can't remember how I put together the PDF view code!
For comment two, this is an old bug in the ImageBox - did you try the latest version of the code (you can get this from the GitHub page - https://github.com/cyotek/Cyotek.Windows.Forms.ImageBox)
Regards; Richard Moss
Misiu
#
Thanks Richard :) I was using old version of ImageBox that was with CodeProject article. After adding Your control using NuGet and some small changes everything is working fine :)
Btw any news about GhostScriptAPI? at line 659 You have TODO item about wrong combination of params. In my case I get this error when I try to open very large pdf (2900 x 6500 pixels).
Again many thanks for this awesome control and API.
Richard Moss
#
I thought that was the case, glad you're up and running with the latest code now.
In regards to the GhostScript library, the project I was going to use it for has been sitting on the backburner for some time now so I haven't been back to it. It's unlikely that I'll get to it any time soon as I have so many other half complete projects I'd like to get done! Hopefully I'll get the chance to look at it sooner than later though.
Regards; Richard Moss
Misiu
#
Hi again, I did some tests and it looks like error was because I had very long file name with spaces and dashes. After changing name to shorter everything works fine :)
Richard Moss
#
Great, thanks for letting me know! That's something the library could automatically work around with a bit of cleverness... if I ever pick the project up again I'll look into it!
Regards; Richard Moss
Dave Gordon
#
Hi, Excellent ImageBox; which I am using in a series of articles over on MSDN.
When we are zoomed in, the Mouse XY coordinates do not relate to the actual Zoomed image coordinates. So we are unable to detect what colour the mouse is hovering over as the mouseXY coordinates differ from the virtual coordinates of the zoom.
How do we get the colour of the pixel the mouse is over regardless of the zoom or panning of the image within the ImageBox container?
Thanks again Richard!
Richard Moss
#
Glad you're finding it useful! You can use the
PointToImage
to convert a point such as that fromMouseEventArgs
into the appropriate location within the image. You can then use that result to query the bitmap either viaBitmap.GetPixel
or via the direct pixels if you have already extracted and stored these viaBitmap.Lockbits
. (The former is going to be slow, especially if you are going to be updating as you move the mouse around, whilst the latter is complicated to explain especially if you use pointers). Both of these assume you are using aBitmap
object even though theImageBox
uses the more genericImage
instead. Although now that I think, I've never tested (or used for that matter) a metafile.PS: I noticed in your article that you're linking to an older version of the code. Might be better to link to the GitHub page for this project instead (https://github.com/cyotek/Cyotek.Windows.Forms.ImageBox) or it's NuGet package (https://www.nuget.org/packages/CyotekImageBox/). Hmm, or maybe I should add an overview page to this site instead of scattered blog posts.
Hope that helps! Regards
schorges
#
Nice work! Very good job, thanks!
But i have one querstion: how do i hide the scrollbar, or set the scrollbar visibile to false?
Richard Moss
#
Basically, you can't. The information needed to handle scroll position is not available if the scrollbars are destroyed. (See this GitHub issue)
I sat down a couple of weeks ago to rework the basic underpinnings of the ImageBox with the intention to fit this, but it's a breaking changed to compatibility to I haven't created binaries for it yet (nor in truth have I finished testing it). If you want the latest source which should fix this, you can get it from the GitHub page.
Hope this helps!
Regards; Richard Moss
Essam Mohamed Zaki
#
Multiple region selection First thanks for this nice project , I have a project which need to select multiple regions from the loaded image, the current image control only select one region , would you guide me to add multiple regions selection and retrieve the selected regions