POV-Ray : Newsgroups : povray.general : Rectangular Image map : Re: Rectangular Image map Server Time
29 Jul 2024 18:24:14 EDT (-0400)
  Re: Rectangular Image map  
From: stbenge
Date: 19 Nov 2010 11:27:57
Message: <4ce6a58d$1@news.povray.org>
On 11/18/2010 5:37 PM, DranoMax wrote:
> Hello everyone, I'm attempting to load a bmp file as an image map onto a box,
> however, it keeps getting cut from it's original resolution into a square shape.
>   Should I be trying to image map onto a different shape, or is there something I
> need to declare?
>
> Thanks

Hi DranoMax,

With the new beta versions of POV-Ray you can use max_extent() to 
retrieve the original size of your image. Here's an example:

// declare the image
#declare image =
pigment{
  image_map{
   sys "some_image.bmp"
  }
}

// get the x/y dimensions of the image (returns a 2D vector)
#declare image_size = max_extent(image);

box{0, 1

  // map image to <0,0>-<1,1>
  pigment{image}

  // center the box
  translate -0.5

  // scale it proportionately so that the box's width equals one unit
  scale image_size/image_size.x
}

It's often easier to map your image to a unit box and just scale from there.

Sam


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.