假如我有一个IMAGE,上面有一副BMP的图片。当我把鼠标放上去的时候,这个图片将会发生变化,也就是使得这个图片发亮或者实现3D的效果。当鼠标移走的时候,再恢复成原来的样子。切记,只用一副图片来实现,千万不要告诉我用两副图片来切换,我不需要这样的方法。急啊,再解决不出来,我要下岗了!!!!

解决方案 »

  1.   

    看delphi的Timage的帮助
    每个函数都有说明
    1.下一个别人写的image类,类里已经实现了你要的功能,
    也可自己继承Timage自己写一个
      

  2.   

    哈哈 你真的要下岗了...
    理由如下:对BMP的每一点操作可以使图片发亮,
    但图片大会闪烁,恢复函数也难写,
    当一些比较亮的颜色变为白色时...使用图形移动可以制作出一定的效果,
    但你千万不能损失象素,也不能多,
    否则恢复函数.....当然你可以在变换前将原BMP保存起来,
    那和两幅图有什么区别 哈哈....
      

  3.   

    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    type
    TRGBColor = record
      R, G, B: Byte;
    end;
    PRGBColor = ^TRGBColor;
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    procedure RGB(var Bmp: TBitmap; R, G, B: Integer);
    var
      X, Y: Integer;
      I: Byte;
      ColorTable: array[0..255] of TRGBColor;
      pRGB: PRGBColor;
    begin
      for I := 0 to 255 do
      begin
        ColorTable[I].R := Byte(I + R);
        ColorTable[I].G := Byte(I + G);
        ColorTable[I].B := Byte(I + B);
      end;  for Y := 0 to Bmp.Height - 1 do
      begin
        pRGB := Bmp.ScanLine[Y];
        for X := 0 to Bmp.Width - 1 do
        begin
          pRGB.R := ColorTable[pRGB.R].R;
          pRGB.G := ColorTable[pRGB.G].G;
          pRGB.B := ColorTable[pRGB.B].B;
        end;
        Inc(pRGB);
      end;
    end;// 改变图像的亮度,也只需调用RGB(Bmp, X, X, X)改变三原色.
    // 调节Bitmap的对比度
    // 应用公式: 新颜色值 = (旧颜色值 - 128) * 系数 + 128
    procedure Contrast(var Bmp: TBitmap; Amount: Integer);
    // Amount: -255~255
    var
      X, Y: Integer;
      I: Byte;
      ColorTable: array[0..255] of TRGBColor;
      pRGB: PRGBColor;
    begin
      for I := 0 to 126 do
      begin
        Y := (Abs(128 - I) * Amount) div 256;
        ColorTable[I].r := GetRValue(Byte(I - Y));
        ColorTable[I].g := GetGValue(Byte(I - Y));
        ColorTable[I].b := GetBValue(Byte(I - Y));
      end;
      for I := 127 to 255 do
      begin
        Y := (Abs(128 - I) * Amount) div 256;
        ColorTable[I].r := GetRValue(Byte(I + Y));
        ColorTable[I].g := GetGValue(Byte(I + Y));
        ColorTable[I].b := GetBValue(Byte(I + Y));
      end;
      for Y := 0 to Bmp.Height - 1 do
      begin
        pRGB := Bmp.ScanLine[Y];
        for X := 0 to Bmp.Width - 1 do
        begin
          pRGB.R := ColorTable[pRGB.R].R;
          pRGB.G := ColorTable[pRGB.G].G;
          pRGB.B := ColorTable[pRGB.B].B;
          Inc(pRGB);
        end;
      end;
    end;// 改变饱和度
    procedure Saturation(var Bmp: TBitmap; Amount: Integer); // Amount: 0~510
    var
      Grays: array[0..767] of Integer;
      Alpha: array[0..255] of Word;
      Gray, X, Y: Integer;
      pRGB: PRGBColor;
      I: Byte;
    begin
      for I := 0 to 255 do Alpha[I] := (I * Amount) shr 8;
      x := 0;
      for I := 0 to 255 do
      begin
        Gray := I - Alpha[I];
        Grays[X] := Gray; Inc(X);
        Grays[X] := Gray; Inc(X);
        Grays[X] := Gray; Inc(X);
      end;
      for Y := 0 to Bmp.Height - 1 do
      begin
        pRGB := Bmp.ScanLine[Y];
        for X := 0 to Bmp.Width - 1 do
        begin
          Gray := Grays[pRGB.R + pRGB.G + pRGB.B];
          pRGB.R := Byte(Gray + Alpha[pRGB.R]);
          pRGB.G := Byte(Gray + Alpha[pRGB.G]);
          pRGB.B := Byte(Gray + Alpha[pRGB.B]);
          Inc(pRGB);
        end;
      end;
    end;
      

  4.   

    to oldcamel33(驼子) 图片大可以做双缓冲解决闪的问题!