Solved

Access pixels (I need for speed!)

Posted on 2004-04-23
12
213 Views
Last Modified: 2010-04-05
Hi Experts,
I want to get about 500 squares with different size from a bitmap and stretch them into 40 x 40 squares. these lines are to slow to do it:

bmp:=Tbitmap.create;
bitmap:=tbitmap.create;
strbitmap:=tbitmap;
bitmap.assign(image1.picture.bitmap);
bmp.canvas.copyrect(rect(0,0,100,100),bitmap.canvas,rect(0,0,100,100));
strbitmap.canvas.stretchdraw(rect(0,0,40,40),bitmap.canvas);

to make 500 of strbitmaps it takes more than a second. how can I make it faster. and also I want to access pixels faster - for example I want to count pixels with redvalue of 200~255. don't tell ScanLine is fast ;)
If DirectX or OpenGL are to solve it, please name some good packages which do that.
Thank U,

Comboy
0
Comment
Question by:Comboy
[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
  • 2
  • 2
  • +1
12 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10900255
ScanLine is fast!

 <SMILE>

Shane
0
 
LVL 1

Author Comment

by:Comboy
ID: 10903075
It's faster with DirectX, isn't it? Oh well, it's not fast in my case... ;)
0
 
LVL 3

Expert Comment

by:Kunfufaresi
ID: 10904794
anything faster than ScanLine existed and I wasnt told??
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:shaneholmes
ID: 10904819
Thanks Kunfufaresi, Im not alone!

Shane
0
 
LVL 3

Expert Comment

by:Kunfufaresi
ID: 10905143
you could read the bitmap into an array like 1..1000000,1..3, with RGB already seperated and work on that if you plan many operations/countings on the same bitmap.
0
 
LVL 3

Expert Comment

by:Kunfufaresi
ID: 10905223
Hello,

here is a doc about scanlines optimization

http://homepages.borland.com/efg2lab/ImageProcessing/Scanline.htm#Examples

it has lots of information about scanlines, but no magic to boost the speed more than 10%, although there is a mention that if you could get access to your PCI/AGP screen card directly the speed dial would jump 10 times, but how to do that it doesnt say, guess you could reverse enginere your screen card drivers! :O

Kunfu Faresi
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 10906737
Hey, Comboy! don't say that ScanLines aren't fast ;) I've made color counter some time ago, that counts all used colors in 1600x1200 picture in about 30 msecs on my PC (and I used ScanLines)!
You said that you want to count pixels with redvalue of 200~255. If you need my alghorithm (you'll have to change some places in it) - just say, I'll copy it here.
0
 
LVL 1

Author Comment

by:Comboy
ID: 10906961
Hi,
ZhaawA > is it the way you count:

var
bitmap:tbitmap;
p:pbytearray;
x,y,q,w,i:integer;
begin
bitmap:=tbitmap.Create;
bitmap.Assign(image1.Picture.Bitmap);
q:=gettickcount;
for i:=0 to 100 do begin
for x:=0 to bitmap.Height-1 do begin
p:=bitmap.ScanLine[x];
for y:=0 to bitmap.Width-1 do begin
if (p[y*3+2]>200) and (p[y*3+2]<255) then begin
p[y*3+0]:=255;
p[y*3+1]:=255;
p[y*3+2]:=255;
end;
end;
end;
end;
w:=gettickcount;
image1.Picture.Bitmap.Assign(bitmap);
showmessage:=(inttostr(w-q));
end;

Ok, image1.height is 240 and image1.width is 320. in this code I looked for 200<redvalue<255 for 100 times. it takes about 32~47 milliseconds by an ATi Radeon 7000 64MB. and 450 milliseconds for 1000 scans.
But I'm sure DirectX can increase it. If you know how to touch top speed with G32 components (or any other accelerators), please let me know.
Thanks
0
 
LVL 3

Accepted Solution

by:
Kunfufaresi earned 70 total points
ID: 10907256
hello have you tried using the libraries at

http://www.ampaze.de/dx/nine/

it has directx and directdraw unit has scanline, but i've not used it before.
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

Suggested Solutions

Title # Comments Views Activity
QRReport  TQrmemo vertical stretching 1 56
Find and Replace Stream with 0s 8 73
Dev express lookupcombo 3 46
Wincontrol not (correctly) drawn 15 48
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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