⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sd0408.h

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 H
字号:
//
// Windows CE Software Graphics Library
// sd0408.h
//
// Copyright (c) 2000 Microsoft Corporation. All rights reserved.
//
// This header file contains the function template for the special blit case
// of 4 Bpp source and 8 Bpp destination. This code will do the appropriate
// lookup and conversion, but not stretch, colorkey, mask, clip, or blend.

#if !defined(FUNCTION)
#error Must define FUNCTION
#endif

#if !defined(BYTE_OP)
#error Must define BYTE_OP
#endif

BOOL
FUNCTION( 
  BLT_PARAM * Parameters
  )
{
  // Local variables.

  // Source-related info.

  const RECT * SrcRect = Parameters->SourceRect;
  LONG         SrcScanStride = Parameters->Source->Stride;
  BYTE       * SrcScanLine  = (BYTE *)Parameters->Source->Ptr +
                              SrcRect->top * SrcScanStride    +
                              (SrcRect->left >> 1);

  // Destination-related info.

  const RECT * DstRect = Parameters->DestRect;
  LONG         DstScanStride = Parameters->Destination->Stride;
  BYTE       * DstScanLine  = (BYTE *)Parameters->Destination->Ptr +
                              DstRect->top * DstScanStride         +
                              DstRect->left;

  ULONG Rows = RectHeight(DstRect);
  ULONG Cols = RectWidth(DstRect);

  ULONG Row;
  ULONG Col;

  BYTE Palette[16];

  ULONG i;

  BYTE * SrcPixel;
  BYTE * DstPixel;
  BYTE   SrcValue;

  BOOL Odd;

  // Check parameters.

  // !TODO!

  // Pre-transform the 4Bpp palette into our color format so that we can just
  // do a straight lookup per-pixel.

  if (!InitColorConverter(Parameters->Source->Format,
                          Parameters->Destination->Format)) {
    return FALSE;
  }

  for (i = 0; i < 16; i++) {

    Palette[i] = (BYTE)ColorConvert(i);
  }

  CleanupColorConverter(); 
    
  for (Row = 0; Row < Rows; Row++) {

    // Set up pointers to first bytes on source and destination scanlines.

    SrcPixel = SrcScanLine;
    DstPixel = DstScanLine;
    Odd = SrcRect->left & 1;

    for (Col = 0; Col < Cols; Col++) {

      if (Odd) SrcValue = *SrcPixel++ & 0xF;
      else     SrcValue = *SrcPixel >> 4;
            
      Odd = !Odd;

      *DstPixel++ = BYTE_OP(*DstPixel, Palette[SrcValue]);
    }

    // Advance to next scanline.

    SrcScanLine += SrcScanStride;
    DstScanLine += DstScanStride;
  }

  return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -