Article View: cn.bbs.comp.program
Article #1568Re: Delphi ͼ��һ��
From: ����
Date: Fri, 03 Apr 1998 00:00
Date: Fri, 03 Apr 1998 00:00
71 lines
2580 bytes
2580 bytes
> [1;36m==> Confidence_Sun(���) ˵��: [37;40m[0m
> �뿴����һ�γ���
> var
> lpLP:PLOGPALETTE;
> Function MakePalette:HPALETTE;
> implementation
> {$R *.DFM}
> procedure TForm1.FormCreate(Sender: TObject);
> var
> dwSize:DWord;
> begin
> dwSize:=sizeof(TLOGPALETTE)+256*sizeof(TPALETTEENTRY);
> lpLP:=plogpalette(LocalAlloc(LMEM_FIXED,dwSize));
LocalAlloc return a handle, not a pointer. You should use GetMem.
> end;
> procedure TForm1.FormPaint(Sender: TObject);
> var
> DCHandle:HDC;
> Palette:HPALETTE;
> i:Integer;
> begin
> if Palette<>0 then
> begin
> DeleteObject(Palette);
> Palette:=0;
> end;
> DCHandle:=GetDC(Canvas.Handle);
> Palette:=MakePalette;
> SelectPalette(DCHandle,Palette,false);
> RealizePalette(DCHandle);
> with Canvas do
> for i:=0 to 255 do
> begin
> Brush.color:=PALETTEINDEX( i );
> Canvas.FillRect( Rect(((i*width) div 256),0,(((1+i)*width) div 256),Height) );
> end;
> DeleteObject(Palette);
> ReleaseDC(Form1.Handle,DCHandle);
> end;
> Function MakePalette:HPALETTE;
> var
> i:Integer;
> Palette:HPalette;
> begin
> lpLP^.palVersion:=$300;
> lpLP^.palNumEntries:=256;
> for i:=0 to 127 do
> begin
> lpLP^.palPalEntry[i].peRed:=((i*256) div 128);
> lpLP^.palPalEntry[i].peGreen:=0;
> lpLP^.palPalEntry[i].peBlue:=0;
> lpLP^.palPalEntry[i].peFlags:=0;
> end;
> for i:=128 to 255 do
> begin
> lpLP^.palPalEntry[i].peRed:=255;
> lpLP^.palPalEntry[i].peGreen:=
> ((256*(i-128)) div 128);
> lpLP^.palPalEntry[i].peBlue:=
> ((256*(i-128)) div 128);
> lpLP^.palPalEntry[i].peFlags:=0;
> end;
> Palette:=CreatePalette(lpLP^);
> Result:=Palette;
> end;
> ���к��������ϣ���ν��ͣ�(95������256ɫģʽ)���ڴ�����Ļش�
--
�� ��Դ: �й�ƴ�BBSվ [bbs.ustc.edu.cn]
Technical Details
Message-ID:
<980403.yL1Lq$PBBS@bbs.ustc.edu.cn>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: fc86e,178c5e6c912394b2,start X-Google-Attributes: gidfc86e,public From: Ambi_A@bbs.ustc.edu.cn (����) Subject: Re: Delphi ͼ��һ�� Date: 1998/04/03 Message-ID: <980403.yL1Lq$PBBS@bbs.ustc.edu.cn> X-Deja-AN: 340504187 Organization: �й�ƴ�BBSվ Newsgroups: cn.bbs.comp.program