Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
This week, we're updating our course layouts and descriptions. Presentation and materials always gently change over time, but just occasionally there's a need to make a step change to clear out some of the old and roll in the new. That's now happening - but over a long and complex site it's not instant and you'll see sections of the site changing up to and including 19th September.

See also [here] for status update
 
How to import GIF file format ?

Posted by jeschoo (jeschoo), 15 August 2004

Can i know how to import a GIF file format image into the canvas? Canu please show me the code...I really dont have any idea...Please help..


Posted by admin (Graham Ellis), 15 August 2004
Is this what you're looking for? :

Code:
image create photo boox -format GIF -file library.gif
canvas .democan -width 600 -height 400
.democan create image 300 200 -image boox
pack .democan


That code creates an image from a GIF file called library.gif, and a canvas that's 600 pixels wide by 400 pixels tall.  It then centres the gif image on the canvas and packs the canvas.  

If you create an image called library.gif in your current directory and run this code under wish, it should work for you. Tcl and Tk canvases make displaying GIF images quite easy!


Posted by admin (Graham Ellis), 15 August 2004
on 08/15/04 at 15:56:36, jeschoo wrote:
Can u have a look at this code? I try to the code in this program but it cant work. Where should i put in the code in the program below? Please help..Thanks

(( snipped - long code example ))



I've provided you with an example of importing a GIF file into a canvas.   You'll need to modify my example to make it appropriate for your needs - for example, I'm sure you'll want to change the canvas size, canvas name, image name, etc. It's not really practical for me to tell you where it should go and how it should be modified - I simply don't know, because I don't know your requirments.

Is the code you provided something you wrote?  If so, I'm surely you can work out how to add the extra lines.  If not, then do you have copyright permission to place it here?  If not, could you please do me a big favour and snip it out of your previous post ...
when you signed up for the forum, you agreed to our condition You also agree not to post any copyrighted material unless the copyright is owned by you or you have consent from the owner of the copyrighted material.

Posted by jeschoo (jeschoo), 15 August 2004
i'm sorry. This is the code that i wrote. It;s ok.anyway thanks for ur help.I really appreciate it.

Posted by admin (Graham Ellis), 15 August 2004
I hope my example can help you amend you code, then, and wish you all the best with that.  As it's you're code, please do feel free to put back a few lines if you have any further specific questions.

We have to be very careful about copyright of code examples pasted up here, as this is a public forum. Once the moderators see a piece of code which looks like it might be copyright material, they have to ask ... and - sorry - occasionally this does mean that we challenge a piece of code that is validly posted, as it turned out to be in this case.  Sadly, many posters don't think about copyright on code ... they're too busy trying to debug / maintain it. We have to ask sometimes

Posted by jeschoo (jeschoo), 15 August 2004
it's ok..can i ask u some question.If there is an object in the canvas, then the requirement is that the objects cannot go out of the canvas area. What code should be writen so that the object wont go out of the area.

Posted by admin (Graham Ellis), 15 August 2004
Let's see ...

by default, the image (object) is placed by coding in the centre point, but you can go for any corner of the middle of any side by specifing extra options.

If the canvas is x1 pixels wide and y1 pixels tall, and the image is x2 pixels wide and y2 pixels tall, then you need to keep

a) The x position of the image between x2 / 2 and x1 - x2 / 2
and
b) The y position of the image between y2 / 2 and y1 - y2 / 2

if you want to use the default (centred) placement and not have any part of the image go outside the canvas (N.B.  You may need the odd +1 or -1 here if you're concerned to be accurate to the pixel, and in this case watch for rounding if the image is an odd number of pixels wide / tall)

Your dragging back my old computer graphic days here  

Posted by jeschoo (jeschoo), 16 August 2004
Graham, thanks for ur kindness. I really appreciate it.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho