如何实现Win2000/XP关机前的屏幕变灰和恢复效果(200分)

  • 主题发起人 主题发起人 yhwd
  • 开始时间 开始时间
以前看過個例子, 不過是象屏幕保護一樣, 做個窗體全屏無邊框, 在裹面實現你說的效果!!!
 
找到的别人的东东:

屏幕变灰:
procedure DarkScreen;
const
bMask: array [0..15] of Byte = ( $33, 0, $CC, 0, $33, 0,
$CC, 0, $33, 0, $CC, 0, $33, 0, $CC, 0);
var
Bitmap: HBITMAP;
Pattern: HBRUSH;
DCScreen: HDC;
OldPattern: HGDIOBJ;
begin
Bitmap := CreateBitmap(8, 8, 1, 1, @bMask);
Pattern := CreatePatternBrush(Bitmap);
DCScreen := GetDC(0);
OldPattern := SelectObject(DCScreen, Pattern);
BitBlt(DCScreen, 0, 0, Screen.Width, Screen.Height, 0, 0, 0, $A000C9);
SelectObject(DCScreen, OldPattern);
ReleaseDC(0, DCScreen);
DeleteObject(Bitmap);
DeleteObject(Pattern);
end;

恢复:
procedure RepaintScreen;
var
r : TRect;
begin
r := Screen.DesktopRect;
InvalidateRect(0, @r, true);
end;
 
apw的程序可用,只是效果不太好。
有没有更好的方法。
 
还不简单,
桌面Copy为图片,再将图片变灰(这点你如果有疑问再问我,我有个函数),再将变灰后的图片Copy到桌面!
 
找到了,变灰的函数是:(速度绝对快!)
procedure GrayBitmap(ABitmap: TBitmap; Value: integer);
var
Pixel: PRGBTriple;
w, h: Integer;
x, y: Integer;
avg: integer;
begin
ABitmap.PixelFormat := pf24Bit;
w := ABitmap.Width;
h := ABitmap.Height;
for y := 0 to h - 1 do
begin
Pixel := ABitmap.ScanLine[y];
for x := 0 to w - 1 do
begin
avg := ((Pixel^.rgbtRed + Pixel^.rgbtGreen + Pixel^.rgbtBlue) div 3)
+ Value;
if avg > 240 then avg := 240;
Pixel^.rgbtRed := avg;
Pixel^.rgbtGreen := avg;
Pixel^.rgbtBlue := avg;
Inc(Pixel);
end;
end;
end;
 
组合了一下,对付用吧。
 
后退
顶部