Browse Prior Art Database

Fitting a Rectangular Image Into an N-Sided Polygon in Java

IP.com Disclosure Number: IPCOM000123230D
Original Publication Date: 1998-Jul-01
Included in the Prior Art Database: 2005-Apr-04
Document File: 2 page(s) / 60K

Publishing Venue

IBM

Related People

Morgan, SA: AUTHOR [+3]

Abstract

Disclosed is a technique for presenting a rectangular image in a non-rectangular polygon of three or more sides using the Java* programming language.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 53% of the total text.

Fitting a Rectangular Image Into an N-Sided Polygon in Java

   Disclosed is a technique for presenting a rectangular
image in a non-rectangular polygon of three or more sides using the
Java* programming language.

   A typical embodiment would be in presenting a rotating
cube which has an image on each side.  As a side rotates into or out
of view, the actual 2-dimensional shape of the side is not
rectangular; for example, the edge that is "closest" to the viewer
is taller than the edge that is "further away" from the user.  The
top and bottom edges are also not parallel, but instead slope toward
the back edge.  The image for that side needs to be fitted to the
non-rectangular shape of that side as drawn in 2-dimensions.  As the
object continues to rotate, the perceived shape of the side will
continue to change until the side is directly facing the viewer, at
which time it will appear rectangular again.

   Steps for fitting a rectangular image into a
non-rectangular, n-sided polygon in Java are as follows:
  1.  Create an offscreen buffer the size of the bounding
      rectangle for the polygon.
  2.  Scale the source image to be the width of the polygon's
      bounding rectangle.
  3.  Fill the image with a background color that will be used
      for transparency.
  4.  Looping through the new scaled image from step 2, left to
      right, deal with each column of pels in the image one at
      a time, extracting the column of pels in the image into
      a new separate 1-pel wide image.
  5.  At the same time work from left to right in the polygon,
      calculating the top and...