<p>I have written code to read a windows bitmap and would now like to display it with ltk. How can I construct an appropriate object? Is there such functionality in ltk? If not how can I do it directly interfacing to tk?</p>

[{'answer_id': 78937, 'author': 'Bryan Oakley', 'author_id': 7432, 'author_profile': 'https://Stackoverflow.com/users/7432', 'pm_score': 2, 'selected': False, 'text': '<p>Tk does not natively support windows bitmap files. However, the "Img" extension does and is freely available on just about every platform. You do not need to read the data in, you can create the image straight from the file on disk. In plain tcl/tk your code might look something like this:</p>\n\n<pre><code>package require Img\nset image [image create photo -file /path/to/image.bmp]\nlabel .l -image $image\npack .l\n</code></pre>\n\n<p>a little more information can be found at <a href="http://wiki.tcl.tk/6165" rel="nofollow noreferrer">http://wiki.tcl.tk/6165</a></p>\n'}, {'answer_id': 104227, 'author': 'Alasdair', 'author_id': 2654, 'author_profile': 'https://Stackoverflow.com/users/2654', 'pm_score': 3, 'selected': True, 'text': '<p>It has been a while since I used LTK for anything, but the simplest way to display an image with LTK is as follows:</p>\n\n<pre><code>(defpackage #:ltk-image-example\n  (:use #:cl #:ltk))\n\n(in-package #:ltk-image-example)\n\n(defun image-example ()\n  (with-ltk ()\n    (let ((image (make-image)))\n      (image-load image "testimage.gif")\n      (let ((canvas (make-instance \'canvas)))\n        (create-image canvas 0 0 :image image)\n        (configure canvas :width 800)\n        (configure canvas :height 640)\n        (pack canvas)))))\n</code></pre>\n\n<p>Unfortunately what you can do with the image by default is fairly limited, and you can only use gif or ppm images - but the <a href="http://en.wikipedia.org/wiki/Portable_pixmap" rel="nofollow noreferrer">ppm file format</a> is very simple, you could easily create a ppm image from your bitmap. However you say you want to manipulate the displayed image, and looking at the code that defines the image object:</p>\n\n<pre><code>(defclass photo-image(tkobject)\n  ((data :accessor data :initform nil :initarg :data)\n   )\n  )\n\n(defmethod widget-path ((photo photo-image))\n  (name photo))\n\n(defmethod initialize-instance :after ((p photo-image)\n                                       &amp;key width height format grayscale data)\n  (check-type data (or null string))\n  (setf (name p) (create-name))\n  (format-wish "image create photo ~A~@[ -width ~a~]~@[ -height ~a~]~@[ -format \\"~a\\"~]~@[ -grayscale~*~]~@[ -data ~s~]"\n               (name p) width height format grayscale data))\n\n(defun make-image ()\n  (let* ((name (create-name))\n     (i (make-instance \'photo-image :name name)))\n    ;(create i)\n    i))\n\n(defgeneric image-load (p filename))\n(defmethod image-load((p photo-image) filename)\n  ;(format t "loading file ~a~&amp;" filename)\n  (send-wish (format nil "~A read {~A} -shrink" (name p) filename))\n  p)\n</code></pre>\n\n<p>It looks like the the actual data for the image is stored by the Tcl/Tk interpreter and not accessible from within lisp. If you wanted to access it you would probably need to write your own functions using <strong>format-wish</strong> and <strong>send-wish</strong>.</p>\n\n<p>Of course you could simply render each pixel individually on a canvas object, but I don\'t think you would get very good performance doing that, the canvas widget gets a bit slow once you are trying to display more than a few thousand different things on it. So to summarize - if you don\'t care about doing anything in real time, you could save your bitmap as a .ppm image every time you wanted to display it and then simply load it using the code above - that would be the easiest. Otherwise you could try to access the data from tk itself (after loading it once as a ppm image), finally if none of that works you could switch to another toolkit. Most of the decent lisp GUI toolkits are for linux, so you may be out of luck if you are using windows.</p>\n'}]
['https://Stackoverflow.com/questions/77934', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1994377/']