Click here to Skip to main content
15,917,795 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: How is BitBlt implemented Pin
El Corazon20-Nov-07 6:30
El Corazon20-Nov-07 6:30 
GeneralRe: How is BitBlt implemented Pin
Force Code20-Nov-07 7:05
Force Code20-Nov-07 7:05 
GeneralRe: How is BitBlt implemented Pin
El Corazon20-Nov-07 7:12
El Corazon20-Nov-07 7:12 
GeneralRe: How is BitBlt implemented Pin
Force Code20-Nov-07 7:35
Force Code20-Nov-07 7:35 
GeneralRe: How is BitBlt implemented Pin
El Corazon20-Nov-07 7:50
El Corazon20-Nov-07 7:50 
GeneralRe: How is BitBlt implemented Pin
Force Code20-Nov-07 8:07
Force Code20-Nov-07 8:07 
GeneralRe: How is BitBlt implemented Pin
Dexterus29-Nov-07 4:18
Dexterus29-Nov-07 4:18 
AnswerRe: How is BitBlt implemented Pin
The Nightcoder27-Nov-07 11:47
The Nightcoder27-Nov-07 11:47 
Hi,

I realize your question is old, but just in case it is still open:

- On the algorithm: The Windows BitBlt API is just an interface to the hardware blitter (BLIT = Binary Large Image Transfer) present on the graphics card or other hardware your'e talking to. If the hardware doesn't have a blitter, the algorithm is just a loop (depending on CPU, it may also be a call to a CPU BLIT instruction if one is available - as in MMX/SSE) similar to the one you've written in previous posts in this thread. That you can't find the function in ActionScript is because the language (like most scripting languages) doesn't like exposing stuff that could result in buffer overruns and similar stuff (it blindly assumes that anyone using it is not a "real programmer" - a common but often self-fulfilling misconception held by script language designers).

- On your thoughts about precalculating and looking up ROP results: Memory cycles are (nowadays) several orders of magnitude slower than CPU cycles, while bitwise logical operations (like ROPs) are extremely fast. Precalculating values and retrieving them by index (which calls not only for memory accesses, but also for address calculations that cost *more* than the ROPs themselves) should normally be noticeably slower than doing the ROPs in the loops.

- On optimization: Try making the ROPs using the computers preferred word length (32/64 bits) if it's not fast enough on the individual bytes. An Intel-style CPU will be almost as fast using bytes but RISCs traditionally have a heavy penalty for using bytes instead of words (the compiler has to shift and mask each byte out of words and back like crazy as the CPU usually only has word-length instructions). Also, do any complex offset (pixel coordinate to byte or word offset) calculations outside of the loop (so that the pixel addressing is just a straight increment inside the loop).

Performance-wise, you'll probably do just fine looping over bytes unless the ActionScript interpreter is junk (never tested it). On a modern CPU this kind of approach is surprisingly close to a hardware blitter in performance for moderately-sized images. I've seen stuff written in C# that does substantially heavier math (such as image rotating) on each pixel than simple ROPs, and performs well enough (even in the debugger) for live animation purposes.

Later,
Peter

QuestionAny one know c4.5 Pin
ibnoe13-Nov-07 14:27
ibnoe13-Nov-07 14:27 
GeneralRe: Any one know c4.5 Pin
John_Adams10-Dec-07 23:36
John_Adams10-Dec-07 23:36 
QuestionSplitting a Polygon into Rectangles Pin
notacake12-Nov-07 3:02
notacake12-Nov-07 3:02 
AnswerRe: Splitting a Polygon into Rectangles Pin
Luc Pattyn12-Nov-07 4:19
sitebuilderLuc Pattyn12-Nov-07 4:19 
GeneralRe: Splitting a Polygon into Rectangles Pin
Skippums16-Nov-07 9:07
Skippums16-Nov-07 9:07 
QuestionAssymetric Encryption Algorithms Pin
Skippums8-Nov-07 8:56
Skippums8-Nov-07 8:56 
AnswerRe: Assymetric Encryption Algorithms Pin
El Corazon8-Nov-07 9:17
El Corazon8-Nov-07 9:17 
AnswerRe: Assymetric Encryption Algorithms Pin
Luc Pattyn8-Nov-07 9:18
sitebuilderLuc Pattyn8-Nov-07 9:18 
QuestionRe: Assymetric Encryption Algorithms Pin
Skippums8-Nov-07 9:33
Skippums8-Nov-07 9:33 
AnswerRe: Assymetric Encryption Algorithms Pin
Luc Pattyn8-Nov-07 9:56
sitebuilderLuc Pattyn8-Nov-07 9:56 
GeneralRe: Assymetric Encryption Algorithms Pin
Skippums8-Nov-07 10:04
Skippums8-Nov-07 10:04 
QuestionDisplay Equations in Articles Pin
Ryan Harm7-Nov-07 12:10
professionalRyan Harm7-Nov-07 12:10 
AnswerRe: Display Equations in Articles Pin
Paul Conrad7-Nov-07 12:21
professionalPaul Conrad7-Nov-07 12:21 
QuestionRe: Display Equations in Articles Pin
Ryan Harm7-Nov-07 12:38
professionalRyan Harm7-Nov-07 12:38 
AnswerRe: Display Equations in Articles Pin
Luc Pattyn7-Nov-07 12:24
sitebuilderLuc Pattyn7-Nov-07 12:24 
GeneralRe: Display Equations in Articles Pin
Ryan Harm7-Nov-07 12:40
professionalRyan Harm7-Nov-07 12:40 
GeneralRe: Display Equations in Articles Pin
Luc Pattyn7-Nov-07 13:12
sitebuilderLuc Pattyn7-Nov-07 13:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.