Beispiel #1
0
void CImageView::Display( view_t handle, int dx, int dy )
{
  Rectangle* r = new Rectangle( 0,0, Width(),Height() );
  Bitmap ^ bmp = gcnew Bitmap( Width(),Height() );

  BitmapData ^ bDat = bmp->LockBits( *r, ImageLockMode::ReadWrite, PixelFormat::Format32bppArgb );

  TBpp32* p = (TBpp32*)(void*)bDat->Scan0;

  int y;
  for (y=0; y<Height(); y++)
  {
    memcpy( p, PixelAddress( 0, y ), sizeof(TBpp32)*Width() );
    p += Width();
  }

  bmp->UnlockBits( bDat );
  delete r;

  handle->DrawImage( bmp, dx,dy, Width(),Height() );
}
Beispiel #2
0
void CImageView::Display( view_t handle, int dx, int dy, int sx, int sy, int sw, int sh )
{
  // 矩形クリップ
  TClipSize blksrc,blkdest;
  blksrc.width = Width(); blksrc.height = Height();
  blkdest.width = Width(); blkdest.height = Height();

  TClipBltInfo info;
  info.sx = sx; info.sy = sy;
  info.sw = sw; info.sh = sh;
  info.dx = dx; info.dy = dy;
  ClipBltInfo( &blksrc, &blkdest, &info );

  if (!ClipBltInfo( &blksrc, &blkdest, &info )) return;

  // 転送サイズだけの作成・ロック
  Bitmap ^ bmp = gcnew Bitmap( info.sw, info.sh );
  Rectangle* r = new Rectangle( 0,0, info.sw, info.sh );
  BitmapData ^ bDat = bmp->LockBits( *r, ImageLockMode::ReadWrite, PixelFormat::Format32bppArgb );

  TBpp32* p = (TBpp32*)(void*)bDat->Scan0;

  int i;
  for (i=info.dy; i<info.dy+info.sh; i++)
  {
    int idx = sizeof(TBpp32)*( (i - info.dy) * info.sw );
    TBpp32* srcadr = (TBpp32*)PixelAddress( 0, info.sy + i-info.dy );
    TBpp32* destadr = (TBpp32*)((BYTE*)p + idx);

    neet::BltCopy( srcadr, info.sx, destadr, 0, info.sw );
  }

  bmp->UnlockBits( bDat );
  delete r;

  Rectangle* dr = new Rectangle( info.dx,info.dy, info.sw,info.sh );

  handle->DrawImage( bmp, *dr, 0,0, info.sw,info.sh, GraphicsUnit::Pixel );
  delete dr;
}