Page 1 of 1
Getting Dyalog to handle .jpg and .tiff image files
Posted: Sun Jul 17, 2011 2:48 am
by michaelk
Although the Dyalog Image object handles bitmap (.bmp) files, Dyalog does not seem to have a facility to handle other frequently used image formats such as .jpg and .tiff which store images in a more compressed way than .bmp. I am wanting to use Dyalog to place both text and imagery on a page that will be printed. Does anyone have experience in using Dyalog to do this using .jpg or .tiff files, rather than .bmp?
Re: Getting Dyalog to handle .jpg and .tiff image files
Posted: Mon Jul 18, 2011 10:21 am
by Dick Bowman
Time for a bit of searching, I think.
There was some discussion of this a while back - the short answer being "use .NET". Whether you like that answer being a whole other topic...
Re: Getting Dyalog to handle .jpg and .tiff image files
Posted: Thu Sep 01, 2011 11:41 am
by Morten|Dyalog
Note that recent versions of Dyalog APL allow you to embed .NET controls within an existing Dyalog form - you do NOT need to rewrite your application using System.Windows.Forms or WPF to take advantage of .NET features. For example:
Code: Select all
∇ ShowJPG;win;⎕USING;picbox;f1
[1] ⍝ Show how to display a JPG in a Dyalog Form using an embedded .NET picturebox
[2]
[3] ⎕USING←',system.drawing.dll' ',System.Windows.Forms.dll'
[4]
[5] f1←⎕NEW'Form'(('Caption' 'JPG Display')('Coord' 'Pixel'))
[6] picbox←f1.⎕NEW'NetControl'(('ClassName' 'System.Windows.Forms.PictureBox')('Posn'(0 0)))
[7] picbox.Image←⎕NEW System.Drawing.Bitmap(⊂'c:\docs\dyalog\logo\dyalogicon.jpg')
[8] f1.Size←picbox.Size←picbox.Image.Size.(Height Width)
[9] ⎕DQ'f1'
∇
- jpgform.png (32.47 KiB) Viewed 34485 times
According to
http://msdn.microsoft.com/en-us/library/at62haz6.aspx, the list of supported file types is BMP, GIF, EXIF, JPG, PNG and TIFF.
Note that the Bitmap class has a number of interesting properties and methods, like GetThumbnailImage and RotateFlip.
Code: Select all
picbox.Image.⎕nl -2
Flags FrameDimensionsList Height HorizontalResolution Palette PhysicalDimension PixelFormat
PropertyIdList PropertyItems RawFormat Size Tag VerticalResolution Width
picbox.Image.⎕nl -3
Clone CreateObjRef Dispose Equals FromFile FromHbitmap FromHicon FromResource FromStream
GetBounds GetEncoderParameterList GetFrameCount GetHashCode GetHbitmap GetHicon
GetLifetimeService GetPixel GetPixelFormatSize GetPropertyItem GetThumbnailImage GetType
InitializeLifetimeService IsAlphaPixelFormat IsCanonicalPixelFormat IsExtendedPixelFormat
LockBits MakeTransparent ReferenceEquals RemovePropertyItem RotateFlip Save SaveAdd
SelectActiveFrame SetPixel SetPropertyItem SetResolution ToString UnlockBits
Re: Getting Dyalog to handle .jpg and .tiff image files
Posted: Sun Sep 04, 2011 12:56 am
by michaelk
Morten has shown how to put .jpg imagery into a Windows form. However, I am wanting to put .jpg imagery in a printer object that I have created using the []WC command. In this object I have put text in specified fonts at specified page positions. I want to intermix this text with .jpg images at specified sizes and page positions under program control. Can this be done now in Dyalog? If so, how?
I know that Dyalog can but .bmp images into a printer object, but I'd like to be able to do this also with .jpg and .tiff imagery.
Re: Getting Dyalog to handle .jpg and .tiff image files
Posted: Sun Sep 04, 2011 8:08 am
by Morten|Dyalog
Well, it CAN be done by extracting the RGB values from the .NET bitmap object created in my example:
Code: Select all
pixels←bm.GetPixel¨(⍳bm.Size.(Width Height))-⎕IO
rgb←pixels.(R G B)
It is rather slow at the moment, but speeding up this kind of repeated references of .NET members is something that we have our sights on for a future version.
Re: Getting Dyalog to handle .jpg and .tiff image files
Posted: Sun Sep 04, 2011 9:12 am
by Phil Last
Morten|Dyalog wrote:Code: Select all
pixels←bm.GetPixel¨(⍳bm.Size.(Width Height))-⎕IO
rgb←pixels.(R G B)
It is rather slow at the moment, ....
Might
pixels←bm.(GetPixel¨)...
be quicker, parenthesising the derived function within its owner, as it is with references to ordinary namespaces holding APL code?
Re: Getting Dyalog to handle .jpg and .tiff image files
Posted: Mon Sep 05, 2011 10:09 am
by Morten|Dyalog
Only marginally... On my laptop:
3404ms to do: Image.GetPixel¨⍳Image.Size.(Width Height)-⎕IO
3395ms to do: Image.(GetPixel¨⍳Size.(Width Height)-⎕IO)
44550 = Image.Size.(Width×Height)
~13 calls per millisecond.
Re: Getting Dyalog to handle .jpg and .tiff image files
Posted: Sat Sep 10, 2011 5:47 am
by neeraj
Another solution would be to use a third party component.
http://www.leadtools.com
Re: Getting Dyalog to handle .jpg and .tiff image files
Posted: Sat Sep 10, 2011 5:48 am
by neeraj
Another solution would be to use a third party component.
http://www.leadtools.com