canvas.pixels[x,y]返回总是-1 
我刚刚还制定了这个象素点为clred,但是出来仍然是-1

解决方案 »

  1.   

    好象不会啊!
    procedure TForm1.Button1Click(Sender: TObject);
    var
      I: integer;
    begin
      Canvas.Brush.Color := clBlue;
      Canvas.FillRect(Rect(0,0,Width,Height));
      I := Canvas.Pixels[10,10];
      ShowMessage(inttostr(i));
    end;
      

  2.   

    在程序里仍然是-1,但是你把inttostr的时候会做字节变动,所以看不出来,
    看到帮助里,有写Read Pixels to learn the color on the drawing surface at a specific pixel position within the current clipping region. If the position is outside the clipping rectangle, reading the value of Pixels returns -1.
    和Not every device context supports the Pixels property. Reading the Pixels property for such a device context will return a value of -1. Setting the Pixels property for such a device context does nothing.
      也指定了这个clipping region,但是好像效果不佳
      

  3.   

    IntToStr(-1)应该就是"-1"吧
    procedure TForm1.Button1Click(Sender: TObject);
    var
      I: integer;
    begin
      Canvas.Brush.Color := clBlue;   //我这里设为clRed和clBlue显示的值是不一样的!
      Canvas.FillRect(Rect(0,0,Width,Height));
      I := Canvas.Pixels[10,10];
      ShowMessage(inttostr(i));
    end;
      

  4.   

    是不一样的,但是单步执行的时候,执行完I := Canvas.Pixels[10,10];i的值是-1
      

  5.   

    ead Pixels to learn the color on the drawing surface at a specific pixel position within the current clipping region我想问题就在这里吧:  'current clipping region'
    我们设断点的时候已经是跳到了DELPHI的编辑器来了!
      

  6.   

    我现在先对Canvas.Pixels[10,10]进行设定颜色,在对这个颜色判断,可以准确锁定这个象素点但是,比如我在form上放两个有色的字体的时候,再去判断字体所在位置的象素颜色的时候,就找不到象素颜色值。我现在就是要取出来form整个版面的所有颜色值,然后做成数据包,但是现在卡在了取象素颜色这里
      

  7.   

    现在我发现了,虽然Canvas.Pixels[10,10]的值是-1,但是判断它的颜色时
    if Canvas.Pixels[10,10] = clred then
    begin
      //1
    end
    else
    begin
     //2
    end;
    单步跟踪的时候不跳到1中,但是实际上执行程序的时候是经过了1的。