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

📄 adkdepth.pas

📁 N年前有个法国小组用Delphi写了一个2D网游(AD&D类型)
💻 PAS
字号:
unit ADKDepth;
{
 projet ADK-ISO (c)2002-2003 Paul TOTH <tothpaul@free.fr>

 http://www.web-synergy.net/naug-land/

}

interface

uses
 Windows;

type
 TPixel16=word;
 TPixel32=cardinal;

 TPalette32=array[0..255] of TPixel32;
 TPalettes32=array[word] of TPalette32;

(*
var
 Width     :integer=800;
 Height    :integer=600;
 Depth     :integer=32;
 BPP       :integer=4;
 Halfwidth :integer=400;
 HalfHeight:integer=300;
 RedMask   :integer=$FF0000;
 GreenMask :integer=$00FF00;
 BlueMask  :integer=$0000FF;
 HalfMask  :cardinal=$FEFEFE;

procedure SetSize(AWidth,AHeight,ADepth:integer);
*)
const
 DEPTH15    =15;
 BPP15      =2;
 RedMask15  =$7C00;
 GreenMask15=$03E0;
 BlueMask15 =$001F;
 HalfMask15 =$7BDE;

const
 DEPTH16    =16;
 BPP16      =2;
 RedMask16  =$F800;
 GreenMask16=$07E0;
 BlueMask16 =$001F;
 HalfMask16 =$F7DE;

const
 DEPTH32    =32;
 BPP32      =4;
 RedMask32  =$FF0000;
 GreenMask32=$00FF00;
 BlueMask32 =$0000FF;
 HalfMask32 =$FEFEFE;

function cvt15(color:TPixel32):TPixel16;
function cvt16(color:TPixel32):TPixel16;

//const
// ColorMask=RedMask or GreenMask or BlueMask;

implementation
(*
procedure SetSize(AWidth,AHeight,ADepth:integer);
begin
 Width:=AWidth;
 HalfWidth:=Width shr 1;
 Height:=AHeight;
 HalfHeight:=Height shr 1;
 Depth:=ADepth;
 case Depth of
  DEPTH15: begin
            BPP:=BPP15;
            RedMask:=RedMask15;
            GreenMask:=GreenMask15;
            BlueMask:=BlueMask15;
            HalfMask:=HalfMask15;
           end;
  DEPTH16: begin
            BPP:=BPP16;
            RedMask:=RedMask16;
            GreenMask:=GreenMask16;
            BlueMask:=BlueMask16;
            HalfMask:=HalfMask16;
           end;
  DEPTH32: begin
            BPP:=BPP32;
            RedMask:=RedMask32;
            GreenMask:=GreenMask32;
            BlueMask:=BlueMask32;
            HalfMask:=HalfMask32;
           end;
 end;
end;
*)
function cvt15(color:TPixel32):TPixel16; // 3 * 5 bits
begin                           // 11111000.11111000.11111000
 result:=(color and $F80000) shr 9
        +(color and $00F800) shr 6
        +(color and $0000F8) shr 3;
end;

function cvt16(color:TPixel32):TPixel16; // 2 * 5 bits + 6 bits
begin                           // 11111000.11111100.11111000
 result:=(color and $F80000) shr 8
        +(color and $00FC00) shr 5
        +(color and $0000F8) shr 3;
end;

end.

⌨️ 快捷键说明

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