Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3321116
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:01:27+00:00 2026-05-17T23:01:27+00:00

hi there here it is my code: procedure TForm4.Button1Click(Sender: TObject); var png: TPNGImage; data:

  • 0

hi there
here it is my 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;

it doesn’t work and it makes the pic messy, I’m sure it’s because of the rgbReserved.
what should i do?

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:01:27+00:00Added an answer on May 17, 2026 at 11:01 pm

    This is how to greyify a bitmap. (And, yes, if you want to greyify a PNG, you first need to get the bitmap data out of it. I think the VCL will do this for you.)

    type
      PRGB32Array = ^TRGB32Array;
      TRGB32Array = packed array[0..MaxInt div SizeOf(TRGBQuad)-1] of TRGBQuad;
    
    procedure MakeGrey(Bitmap: TBitmap);
    var
      w, h: integer;
      y: Integer;
      sl: PRGB32Array;
      x: Integer;
      grey: byte;
    begin
      Bitmap.PixelFormat := pf32bit;
      w := Bitmap.Width;
      h := Bitmap.Height;
      for y := 0 to h - 1 do
      begin
        sl := Bitmap.ScanLine[y];
        for x := 0 to w - 1 do
          with sl[x] do
          begin
            grey := (rgbBlue + rgbGreen + rgbRed) div 3;
            rgbBlue := grey;
            rgbGreen := grey;
            rgbRed := grey;
          end;
      end;
    end;
    

    Sample usage:

    procedure TForm4.Button1Click(Sender: TObject);
    var
      bm: TBitmap;
    begin
      bm := TBitmap.Create;
      try
        bm.LoadFromFile('C:\Users\Andreas Rejbrand\Pictures\Porträtt, litet, kvadratiskt.bmp');
        MakeGrey(bm);
        Canvas.Draw(0, 0, bm);
      finally
        bm.Free;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

procedure TForm1.Timer2Timer(Sender: TObject); var ff : integer; begin for ff := 0 to 32
Here I provide simple piece of code. function GetStringList:TStringList; var i:integer; begin Result:=TStringList.Create; Result.Add('Adam');
Here's is my code: type TNav = class(TPanel) private procedure CMMouseEnter(var AMsg: TMessage); message
I am compiling a legacy C code here and there is a lot of
There is a weird code here that I need to make work.. can you
We have some old C code here that's built with nmake. Is there an
i'm trying wmd editor over ajax. here there is the bugged code wdm code
There are some questions on Code Metrics here, especially this one on goal values.
here is the code: http://jsfiddle.net/duNHJ/2/ Basically there is an animations every div so when
Here's my code, I know there's a small mistake somewhere but being a noob

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.