Esempio n. 1
0
int bitbltDepthValue(unsigned short * target,  unsigned int tX,  unsigned int tY  , unsigned int targetWidth , unsigned int targetHeight ,
                     unsigned short DepthVal ,
                     unsigned int width , unsigned int height)
{
  //Check for bounds -----------------------------------------
  if (tX+width>=targetWidth) { width=targetWidth-tX-1;  }
  if (tY+height>=targetHeight) { height=targetHeight-tY-1;  }
  //----------------------------------------------------------

  unsigned short * targetPTR; unsigned short * targetLineLimitPTR; unsigned short * targetLimitPTR;   unsigned int targetLineSkip;
  targetPTR      = target + MEMPLACE1(tX,tY,targetWidth);
  targetLimitPTR = target + MEMPLACE1((tX+width),(tY+height),targetWidth);
  targetLineSkip = (targetWidth-width);
  targetLineLimitPTR = targetPTR + (width) -1 ;

  fprintf(stderr,"BitBlt Depth an area (%u,%u) of target image  starting at %u,%u  sized %u,%u with Depth(%u)\n",width,height,tX,tY,targetWidth,targetHeight,DepthVal);
  while ( targetPTR < targetLimitPTR )
  {
     while (targetPTR < targetLineLimitPTR)
     {
        //fprintf(stderr,"Reading Triplet sourcePTR %p targetPTR is %p\n",sourcePTR  ,targetPTR);
        *targetPTR = DepthVal; ++targetPTR;
     }
    targetLineLimitPTR += targetWidth;
    targetPTR+=targetLineSkip;
  }
 return 1;
}
Esempio n. 2
0
int bitbltDepth(unsigned short * target,  unsigned int tX,  unsigned int tY  , unsigned int targetWidth , unsigned int targetHeight ,
                unsigned short * source , unsigned int sX,  unsigned int sY  , unsigned int sourceWidth , unsigned int sourceHeight ,
                unsigned int width , unsigned int height)
{
  if ( (target==0)||(source==0) ) { return 0; }
  if ( (width==0)||(height==0) ) { return 0; }
  if ( (sourceWidth==0)&&(sourceHeight==0) ) { return 0; }

  //Check for bounds -----------------------------------------
  if (tX+width>=targetWidth) { width=targetWidth-tX-1;  }
  if (tY+height>=targetHeight) { height=targetHeight-tY-1;  }

  if (sX+width>=sourceWidth) { width=sourceWidth-sX-1;  }
  if (sY+height>=sourceHeight) { height=sourceHeight-sY-1;  }
  //----------------------------------------------------------
  if ( (width==0)||(height==0) ) { return 0; }

  unsigned short * sourcePTR;  unsigned short* sourceLineLimitPTR; unsigned short * sourceLimitPTR; unsigned int sourceLineSkip;
  unsigned short * targetPTR;  /*unsigned short * targetLimitPTR;*/    unsigned int targetLineSkip;


  sourcePTR      = source+ MEMPLACE1(sX,sY,sourceWidth);
  sourceLimitPTR = source+ MEMPLACE1((sX+width),(sY+height),sourceWidth);
  sourceLineSkip = (sourceWidth-width)  ;
  sourceLineLimitPTR = sourcePTR + (width) -1;
  //fprintf(stderr,"SOURCE (Depth %u/%u)  Starts at %u,%u and ends at %u,%u\n",sourceWidth,sourceHeight,sX,sY,sX+width,sY+height);

  targetPTR      = target + MEMPLACE1(tX,tY,targetWidth);
  //targetLimitPTR = target + MEMPLACE1((tX+width),(tY+height),targetWidth);
  targetLineSkip = (targetWidth-width)  ;
  //fprintf(stderr,"TARGET (Depth %u/%u)  Starts at %u,%u and ends at %u,%u\n",targetWidth,targetHeight,tX,tY,tX+width,tY+height);

  while (sourcePTR < sourceLimitPTR)
  {
     while (sourcePTR < sourceLineLimitPTR)
     {
        *targetPTR =  *sourcePTR;
        ++targetPTR; ++sourcePTR;
     }

    sourceLineLimitPTR+= sourceWidth;
    targetPTR+=targetLineSkip;
    sourcePTR+=sourceLineSkip;
  }
 return 1;
}
Esempio n. 3
0
unsigned int countDepthAverage(unsigned short * source, unsigned int sourceWidth , unsigned int sourceHeight ,
                                unsigned int sX,  unsigned int sY  , unsigned int tileWidth , unsigned int tileHeight)
{
  //Check for bounds -----------------------------------------
  if (sX+tileWidth>=sourceWidth) { tileWidth=sourceWidth-sX-1;  }
  if (sY+tileHeight>=sourceHeight) { tileHeight=sourceHeight-sY-1;  }
  //----------------------------------------------------------

  unsigned short * sourcePTR; unsigned short * sourceLineLimitPTR; unsigned short * sourceLimitPTR;   unsigned int sourceLineSkip;
  sourcePTR      = source + MEMPLACE1(sX,sY,sourceWidth);
  sourceLimitPTR = source + MEMPLACE1((sX+tileWidth),(sY+tileHeight),sourceWidth);
  sourceLineSkip = (sourceWidth-tileWidth);
  sourceLineLimitPTR = sourcePTR + (tileWidth) -1 ;

  //fprintf(stderr,"Getting Average Depth at area (%u,%u) of source image  starting at %u,%u  sized %u,%u \n",tileWidth,tileHeight,sX,sY,sourceWidth,sourceHeight);
  unsigned int curDepth = 0;
  unsigned int totalDepth = 0;
  unsigned int totalMeasurements = 0;

  while ( sourcePTR < sourceLimitPTR )
  {
     while (sourcePTR < sourceLineLimitPTR)
     {
        //fprintf(stderr,"Reading Triplet sourcePTR %p targetPTR is %p\n",sourcePTR  ,targetPTR);
        if (*sourcePTR!=0)
             {
               curDepth = (unsigned int) *sourcePTR;
               totalDepth += curDepth;
               ++totalMeasurements;
             }
        ++sourcePTR;
     }
    sourceLineLimitPTR += sourceWidth;
    sourcePTR+=sourceLineSkip;
  }
 //fprintf(stderr,"Initial total is %u after %u measurments \n",totalDepth,totalMeasurements);

 if (totalMeasurements==0) { return 0; }
 return (unsigned int) (totalDepth / totalMeasurements);
}
Esempio n. 4
0
unsigned short getDepthPixel(unsigned short * ptrDepth , unsigned int Depthwidth , unsigned int Depthheight ,  unsigned int x , unsigned int y)
{
 unsigned short * ptr =  ptrDepth  + MEMPLACE1(x,y,Depthwidth);
 return *ptr;
}
Esempio n. 5
0
int setDepthPixel(unsigned short * ptrDepth , unsigned int Depthwidth , unsigned int Depthheight ,  unsigned int x , unsigned int y , unsigned short depthValue)
{
 unsigned short * ptr =  ptrDepth  + MEMPLACE1(x,y,Depthwidth);
 *ptr = depthValue;
 return 1;
}