title: converting a PNGImage to grayscale using delphi
body: <p>hi there
  here it is my code:</p>
  
  <pre><code>procedure TForm4.Button1Click(Sender: TObject);
  var
    png: TPNGImage;
    data: PRGBQarray;
    p: ^tagRGBQuad;
    i, o: integer;
  begin
    png := TPNGImage.Create;
    try
      png.LoadFromFile('C:\Untitled.png');
      for o := 1 to 100 do
      begin
        data:=png.Scanline[o];
        for I := 1 to 400 do
        begin
          p := @data^[i];
          p.rgbGreen := p.rgbBlue;
          p.rgbRed := p.rgbGreen;
        end;
      end;
      img.picture.Assign(png);
    finally
      png.Free;
    end;
  end;
  </code></pre>
  
  <p>it doesn't work and it makes the pic messy, I'm sure it's because of the rgbReserved.
  what should i do?</p>