Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to traverse pixels in Monochrome Bitmap (pf1bit)

Posted on 1999-01-14
4
Medium Priority
?
1,304 Views
Last Modified: 2008-03-17
Sir,
     Basically I want to traverse each pixel in a monochrome bitmap. I tried using PByteArray (for Scanline..) and to loop through the bitmap I've also given Bitmap.Width - 8.
But this method is not working. In Short I want to traverse each pixel, get color info for that pixel and do some calculations based on it,
Please Help me out.
Regards, Jagan
0
Comment
Question by:rjagan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1356560
Hi Jagan,

you can either use the ScanLine property. Perhaps the following example from the delphi help file will help you with that...

The problem with this ScanLine property is that you have to bother with things like color depth.
So the example below works only with 256 color bitmaps.

procedure TForm1.Button1Click(Sender: TObject);

// Zeichnung direkt in das BitMap-Objekt ausgeben
var
  x,y : integer;
  BitMap : TBitMap;
  P : PByteArray;
begin
  BitMap := TBitMap.create;
  try
    BitMap.LoadFromFile('..\Images\Splash\256color\factory.bmp');
    for y := 0 to BitMap.height -1 do
    begin
      P := BitMap.ScanLine[y];
      for x := 0 to BitMap.width -1 do
        P[x] := y;
    end;
  canvas.draw(0,0,BitMap);
  finally
    BitMap.free;
  end;
end;

Or you could use the bitmap.canvas.pixels property, which is easier to use, but much much slower...

Regards, Madshi.
0
 

Accepted Solution

by:
DOsinga earned 120 total points
ID: 1356561
You might also have a try with the WinApi GetDIBits functions. This will allow you to copy the pixels of the bitmap in a format of your choice, to be specified in a passed TBitmapInfo.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1356562
YOu go pixel by pixel through the bitmap in order to get eac pixel and do some calculations top it...


for y := 0 to Bitmap.Height do
  for x := 0 to Bitmap.Width do
    bitmap.canvas.pixels[x, y] := bitmap.canvas.pixels[x, y] xor $fafafafa;

-Viktor
--Ivanov
0
 

Author Comment

by:rjagan
ID: 1356563
Thanks a lot for your consideration
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question