POV-Ray : Newsgroups : povray.programming : Programming Help Wanted Server Time
28 Jul 2024 14:21:32 EDT (-0400)
  Programming Help Wanted (Message 1 to 4 of 4)  
From: michael k
Subject: Programming Help Wanted
Date: 10 Sep 2001 18:16:38
Message: <3b9d3bc6@news.povray.org>
Hi all

Can anyone help me with the following?

I want to be able to read in an image and store the colour information for
each pixel in an array.

#declare ImageArray = array[ImageWidth][ImageHeight][3] // 3 = RGB

As far as I can see this could be done with the File I/O functions in POV,
but I don't know enough to be able to write what is needed to decode an
image format and populate the array.  I'm not too bothered about which image
format is used as it's easy enough to convert as required.
Any help with this will be most appreciated, and of course credited where it
is used:)

Thanks in advance

Michael


Post a reply to this message

From: Warp
Subject: Re: Programming Help Wanted
Date: 10 Sep 2001 19:27:37
Message: <3b9d4c69@news.povray.org>
michael.k <mic### [at] ntlworldcom> wrote:
: As far as I can see this could be done with the File I/O functions in POV,

  Nope, it's not possible to read a binary file (nor even most ascii files)
with POV-Ray file I/O. POV-Ray can only read ascii files with certain structure
(mainly POV-Ray compatible items separated with commas).

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: Warp
Subject: Re: Programming Help Wanted
Date: 10 Sep 2001 19:36:13
Message: <3b9d4e6d@news.povray.org>
However, you can achieve this by using pigment functions.

  This is an example which supposes that "image.png" is 160x120:


#declare Image =
  function
  { pigment { image_map { png "image.png" } }
  }

#default { finish { ambient 1 } }

union
{ #declare IndY = 0;
  #while(IndY < 120)
    #declare IndX = 0;
    #while(IndX < 160)

      #declare Color = Image(IndX/160, IndY/120, 0); // The trick

      box { <IndX,IndY,0><IndX+1,IndY+1,1> pigment { color Color } }
      #declare IndX = IndX+1;
    #end
    #declare IndY = IndY+1;
  #end
  translate <-160/2, -120/2>
  scale 1/160
}

camera { location -z look_at 0 }


-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: michael k
Subject: Re: Programming Help Wanted
Date: 11 Sep 2001 19:13:35
Message: <3b9e9a9f@news.povray.org>
Thanks Warp

This is exactly what I wanted to do.

Michael


Warp <war### [at] tagpovrayorg> wrote in message news:3b9d4e6d@news.povray.org...
>   However, you can achieve this by using pigment functions.
>
>   This is an example which supposes that "image.png" is 160x120:
>
>
> #declare Image =
>   function
>   { pigment { image_map { png "image.png" } }
>   }
>
> #default { finish { ambient 1 } }
>
> union
> { #declare IndY = 0;
>   #while(IndY < 120)
>     #declare IndX = 0;
>     #while(IndX < 160)
>
>       #declare Color = Image(IndX/160, IndY/120, 0); // The trick
>
>       box { <IndX,IndY,0><IndX+1,IndY+1,1> pigment { color Color } }
>       #declare IndX = IndX+1;
>     #end
>     #declare IndY = IndY+1;
>   #end
>   translate <-160/2, -120/2>
>   scale 1/160
> }
>
> camera { location -z look_at 0 }
>
>
> --
> #macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
> rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
> ],13),8)-3,10>#end blob{N(array[6]{11117333955,
> 7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

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