Jump to content
LordJashin

Very nice tut on delphi drawing

Recommended Posts

For drawing, and bitmap drawing.

 

Like on that page, it described canvas/bitmap drawing with pixels property, line to, and scan line method. Then it showed a new one that was faster than all 3...here:

 

Still uses scan line, but only once:

When pointer Pbase points to the memory location of pixel [0,0],

Pbase + 4 points to [1,0] and Pbase - 16 points to [0,1]

 

Using ScanLine only once to obtain Pbase, we can access pixels in the following way

[scar]

//assume bitmap width of 100 pixels, 32 bit format

type PDW = ^DWORD;

var Pbase,Pline,p : PDW;

begin

Pbase := bm.scanline[0];

Pline := PDW(DWORD(Pbase) - y * 400);//Pline points to [0,y] as scanline did before

p := PDW(DWORD(Pline) + (x shl 2));//p points to element x on selected row

p^ := $ff00ff;//set pixel [x,y] to color purple

.........

........

end;

 

[/scar]

 

XDot method (what the guy called it), is the method shown above... here are the time results

 

dMoe6.png

Link to comment
Share on other sites

Like, TSCARBitmap.DrawTo, and TSCARBitmap.Pixels.

 

I think these would be faster if the xdot method was used?

 

Definitely the canvas stuff would be faster probably.

 

Neither DrawTo or Pixels would be faster and I'm pretty sure xdot is something he made up... I've been doing this for longer than I can remember, I already know all of the stuff in that article... I've spent years on learning optimization techniques, so most of my code is either as fast as it could be as as fast as it should be within the requirements of the application. My point is, have some faith that I know what I'm doing?

Link to comment
Share on other sites

So would SCAR's TCanvas be faster than this xdot method? Is SCAR TCanvas different from the traditional one from Delphi?

 

Hmm, TCanvas is just TCanvas, if it was something else it would probably be named TSCARCanvas. I do plan on adding more drawing methods directly into TSCARBitmap in the future though, which will be a lot faster than the ones in TCanvas. But at the moment this isn't very high up on my priorities list as the speed of drawing with TCanvas in SCAR should be fast enough for most, if not all applications.

Link to comment
Share on other sites

Okay sounds good. I think I'll use this XDot method inside the TPAGod app. I am remaking it atm. Going to model it a lot after that delphi drawing page.

Might even use some of the functions he made for his bitmap class (Xbitmap).

 

However, i renamed the TpaGod thing to SCAR Tool. Just sounds better that way. And with its select window thingy, it resembles SCAR in that way? Well w/e...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...