Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
Get Image Width and Height without loading the image
Rank: Advanced Member
Groups: Guest
Joined: 3/3/2008(UTC) Posts: 185
Thanks: 8 times
|
Hi, I need a very fast way to know if an image is portrait or landscape or square. My current version is loading the picture into size 80 thumbnail, and check on the orientation. Code:
Dim thumbnail As New Aurigma.GraphicsMill.Bitmap
' Create appropriate format reader.
Dim reader As Aurigma.GraphicsMill.Codecs.FormatReader = _
Aurigma.GraphicsMill.Codecs.FormatManager.CreateFormatReader(FileName)
' LoadFrame returns a frame object.
' From this frame we can get a thumbnail.
Dim frame As Aurigma.GraphicsMill.Codecs.Frame = reader.LoadFrame(0)
frame.GetThumbnail(thumbnail, 80, 0)
frame.Dispose()
reader.Dispose()
If thumbnail.Width > thumbnail.Height Then
lLandscape = lLandscape + 1
ElseIf thumbnail.Height > thumbnail.Width Then
lPortrait = lPortrait + 1
Else
lSquare = lSquare + 1
End If
thumbnail.Dispose()
May I know is there any other better / faster way? It will be great if it don't even need to load the image. Edited by user Wednesday, March 26, 2008 8:25:26 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello, Yeap, of course - you can use IFrame.Width and IFrame.Height properties. They contain correct values independently of the IFrame.GetBitmap(...) method call. I modified your sample a little to illustrate the way: Code:Aurigma.GraphicsMill.Codecs.IFormatReader reader =
Aurigma.GraphicsMill.Codecs.FormatManager.CreateFormatReader("x:/allformats/24bppRgb_Kite.jpg");
using (Aurigma.GraphicsMill.Codecs.IFrame frame = reader.LoadFrame(0))
{
if (frame.Width > frame.Height)
{
//Landscape
}
else if (frame.Width < frame.Height)
{
//Portrait
}
else
{
//Square
}
}
reader.Close();
reader.Dispose();
Edited by user Wednesday, March 26, 2008 8:25:54 PM(UTC)
| Reason: Not specified |
|
|
|
|
Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
Get Image Width and Height without loading the image
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.