SunQuest
 
       JavaScript
  Home arrow JavaScript arrow Page 2 - Zooming in on Images with JavaScript
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Zooming in on Images with JavaScript
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2008-03-04

    Table of Contents:
  • Zooming in on Images with JavaScript
  • Developing a basic front-end
  • Defining a couple of handy JavaScript functions
  • Attaching the JavaScript functions to the zooming controls

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th -1:00PM EST. Register Today!

    Zooming in on Images with JavaScript - Developing a basic front-end


    (Page 2 of 4 )

    As I stated in the introduction of this tutorial, the first step that I’m going to take toward the development of a JavaScript application that will be capable of zooming in and out a concrete bitmapped image will consist of building a simple front-end. This will be handy for placing the image that will be manipulated later into the respective web page.

    Now have a look at the signature of the following (X)HTML file, which displays two simple containing DIVs on the browser. As you’ll see, the first one will be responsible for housing the sample image that will be zoomed in and out via JavaScript. The second one will include a pair of web form buttons for implementing a primitive control panel.

    The corresponding code sample is as follows:


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <title>Zooming images with JavaScript</title>

    <style type="text/css">

    body{

    padding: 0;

    margin: 0;

    background: #eee;

    }

    h1{

    font: bold 14pt Arial, Helvetica, sans-serif;

    color: #000;

    text-align: center;

    }

    img{

    position: absolute;

    }

    #container{

    position: relative;

    width: 263px;

    height: 150px;

    margin-left: auto;

    margin-right: auto;

    overflow: hidden;

    background: #9cf;

    border: 1px solid #000;

    }

    #controlpanel{

    width: 263px;

    margin-left: auto;

    margin-right: auto;

    background: #9cf;

    text-align: center;

    border: 1px solid #000;

    }

    </style>

    </head>

    <body>

    <h1>Zooming images with JavaScript</h1>

    <div id="container"><img src="sample_image.jpg" width="263" height="150"
    id="image" /></div>

    <div id="controlpanel">

    <p><input type="button" id="button1" value="+" /><input type="button"
    id="button2" value="-" /></p>

    </div>

    </body>

    </html>


    As you can see, the signature corresponding to the above (X)HTML file is indeed very easy to grasp. As I stated before, this file includes two main DIVs. The first one, which is identified as “container,” wraps the sample image to be zoomed in and out, and the last one acts merely like a containing element for the controls that will perform the pertinent zooming process on the target image. Not too difficult to understand, right?

    In addition, I styled this pair of containing DIVs, which results in a web document that has the following visual presentation:



    As illustrated by the previous screen shot, the front-end that corresponds with the zooming JavaScript application is very primitive, so you shouldn’t have major problems understanding how it works.

    So far, so good. At this moment everything has been set up correctly. It’s time to leap forward and start coding the respective JavaScript functions that will be tasked with zooming in and out of the previous sample image via the respective zoom controls. Things are getting really exciting now!

    However, to see how these brand new JavaScript functions will be created, you’ll have to click on the link that appears below and keep reading.

    More JavaScript Articles
    More By Alejandro Gervasio


       · Zooming in on bitmapped images with JavaScript is actually a simple process that can...
     

    JAVASCRIPT ARTICLES

    - Using the Style Object for Zebra Tables with...
    - Binary Searching
    - An Improved Approach to Building Zebra Tables
    - Assigning Background Colors Dynamically to Z...
    - Building Zebra Tables with CSS and JavaScript
    - JavaScript: Array Objects
    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...
    - Bulleted Menu of Links
    - Creating Click Loggers and Basic Markers wit...
    - Adding Pan Controls to Yahoo! Maps
    - Adding Zoom Controls to Yahoo! Maps
    - Working with Yahoo! Maps
    - Building Image Zooming Controls with the DOM...
    - Working with Multiple Graphics for a Zoom Ap...

    Iron Speed

    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway