Main Page | Namespace List | Compound List | File List | Compound Members | File Members

vs.cc

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------
00002  *
00003  * (C) Copyright Koninklijke Philips Electronics NV 2006. 
00004  * All rights reserved. This software is licensed under the terms of
00005  * version 2.1 of the GNU Lesser General Public License as published 
00006  * by the Free Software Foundation. For licensing and warranty
00007  * information, see the file COPYING in the main directory.
00008  *
00009  *------------------------------------------------------------------*/
00010 
00011 #include "vs.h"
00012 
00013 using namespace std;
00014 
00015 VS::VS(
00016   const Id&           n, 
00017   In<VYApixel>&       Cin,
00018   In<VYAimageWidth>&  imageWidthIn,
00019   In<VYAimageHeight>& imageHeightIn,
00020   In<VYAimageHeight>& outImageHeightIn,
00021   Out<VYApixel>&      Cout)
00022 :
00023   Process(n),
00024   CinP(             id("CinP"),             Cin),
00025   imageWidthInP(    id("imageWidthInP"),    imageWidthIn),
00026   imageHeightInP(   id("imageHeightInP"),   imageHeightIn),
00027   outImageHeightInP(id("outImageHeightInP"),outImageHeightIn),
00028   CoutP(            id("CoutP"),            Cout)
00029 { 
00030 }
00031 
00032 void VS::main()
00033 {
00034   while (true)
00035   {
00036     VYAimageWidth imageWidth;
00037     VYAimageHeight imageHeight;
00038     VYAimageHeight outImageHeight;
00039     double index;
00040     double scaleFactor;
00041     
00042     read(imageWidthInP, imageWidth);
00043     read(imageHeightInP, imageHeight);
00044     read(outImageHeightInP, outImageHeight);
00045 
00046     index = 0;
00047     scaleFactor = (double)outImageHeight / (double)imageHeight;
00048         
00049     VYApixel* line = new VYApixel[imageWidth];
00050     
00051     if (scaleFactor <= 1) /* compress */
00052     {
00053       for (unsigned int i=0; i<imageHeight; i++)
00054       {
00055         read(CinP, line, imageWidth);
00056         if (index <= i)
00057         {
00058           write(CoutP, line, imageWidth);
00059           index += 1/scaleFactor;
00060         }
00061       }
00062     }
00063     else /* expand */
00064     {
00065       for (unsigned int i=0; i<outImageHeight; i++)
00066       {
00067         if (index <= i)
00068         {
00069           read(CinP, line, imageWidth);
00070           index += scaleFactor;
00071         }     
00072         write(CoutP, line, imageWidth);
00073       }
00074     }
00075     
00076     delete [] line;
00077   }
00078 }

Generated on Wed Feb 15 14:52:44 2006 for scaling by doxygen 1.3.2