如何改变image中图片的颜色呢???

解决方案 »

  1.   


     TColor的格式:$0Nbbggrr 
    N的说明: 
    If the highest-order byte is zero, the color obtained is the closest matching color in the system palette.  
    如果头字节是0,颜色被匹配到最接近的系统调色板。 
    If the highest-order byte is one ($01 or 0x01), the color obtained is the closest matching color in the currently realized palette. 
    如果头字节是1,颜色被匹配到当前调色板。 
    If the highest-order byte is two ($02 or 0x02), the value is matched with the nearest color in the logical palette of the current device context. 
    如果头字节是2,颜色被匹配到当前设备上下文的逻辑调色板中最接近的颜色。 
    COLORREF 
    When specifying an explicit RGB color, the COLORREF value has the following hexadecimal form: 0x00bbggrr //注意这里。头字节是空的,即等于0  The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green; and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.  如上,注意TColor的头字节,有可能,你使用API得到的是COLORREF的值,而程序使用的是逻辑值,或程序特有的调色板。也就是说,你可能需要得到特定的调色板信息。 
     
      

  2.   

    照片底片效果unit Unit1;interfaceuses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, shellapi,OleCtrls, SHDocVw, Menus, ExtCtrls, ComCtrls;type
    TForm1 = class(TForm)Image1: TImage;Button1: TButton;P: TProgressBar;procedure Button1Click(Sender: TObject);    private
    { Private declarations }public{ Public declarations }end;varForm1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);var r,g,b,i,j:integer;begin
      
      p.Max:=image1.Width;
      
      for i:=0 to image1.Width-1 do
      
      begin
        
        p.Position:=i;
        
        for j:=0 to image1.Height-1 do
        
        begin
          
        r:=255-getrvalue(image1.Canvas.Pixels[i,j]);//取得各点红色值
        g:=255-getgvalue(image1.Canvas.Pixels[i,j]);//取得各点绿色值
        b:=255-getbvalue(image1.Canvas.Pixels[i,j]);//取得各点蓝色值
        image1.Canvas.Pixels[i,j]:=rgb(r,g,b);//重新设置各点的rgb值    end;
        
        image1.Refresh;
        
      end;
      
    end;
    end.
      

  3.   

    我现在用下列代码:
    for i:=0 to imgHair.Picture.Width-1 do
      begin
         for j:=0 to imgHair.Picture.Height-1 do
           begin
              imghair.Picture.Bitmap.Canvas.Pixels[i,j]:=myColor;
           end;
      end;
    imghair.Refresh;
    可是改变的是Image的颜色,并没有改变image中图片的颜色,并且image中图片就没有了,这是怎么回事
      

  4.   

    我只是想改变Image中图片的颜色但是现在连Image的颜色也改变了
      

  5.   

    首先保证你的image中是bmp图像,不能是jpg图像var
      i,j:integer;
    begin
      for i:=0 to imghair.Picture.Width-1 do
        begin
          for j:=0 to imghair.Picture.Height-1 do
            begin
                imghair.Picture.Bitmap.Canvas.Pixels[i,j]:=RGB(Random(255),Random(255),Random(255));
            end;
        end;  imghair.Refresh;
    end;