From: barrett@cs.umass.edu (Daniel Barrett)
Newsgroups: comp.sys.amiga.programmer
Subject: Re: Fastest way to copy 1 pixel?
Date: 21 Jun 1994 17:56:54 GMT

In article <1994Jun20.114241.21775@cc.usu.edu>,   wrote:
>As the title says, what is the fastest way to copy a single pixel
>directly from one bitmap to another....

	A single pixel?  That's trivial.  Here is the most speedy method
I know, and it's sure to impress your programmer friends.

(0)	Start with your pixel, P.  Suppose it is in a bitmap B1.
(1)	Initialize a new BitMap structure, B2.
(2)	Open a 640x400 high-res, interlaced screen.  Open it behind all
	the others so it isn't visible.
(3)	Copy your pixel P to every pixel in the screen, using the
	undocumented OS function WaitBlitBitMapRastBlastBlortPort().
(4)	Compute the average pixel value on your screen, V.
(5)	Spawn a subtask that allocates all available memory, performs an
	inverse Fast Fourier Transform on V, and writes the result to
	address 0 in the Kickstart ROM.  Make sure to enclose the code
	in a Forbid()/Permit() pair.
(6)	Read Kickstart address 0 and write the value to bitmap B2.
(7)	Proudly write your signature in the 640x400 screen using the
	"GoatEntrails" font, size 19, and then close the screen.
(8)	Repeat steps (2)-(7) for every pixel in bitmap B1.
(9)	When you're done, just for laughs, SetFunction the OpenLibrary()
	call to emit rude noises from the audio outputs.

	If you do this properly, it takes less than 0.000000000000000009
nanoseconds, and you'll have an immense feeling of gratification.

                                                        Dan

 //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
| Dan Barrett -- Computer Science Dept, University of MA, Amherst, MA 01003 |
| http://zoo.cs.umass.edu/~barrett/public.html   --    barrett@cs.umass.edu |
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////////
---
Copyright 1994 by Daniel J. Barrett.  All rights reserved.
This article may be freely distributed as long as it is distributed in its
entirety.  It may not be included in any publication without the written
permission of the author.  So nyaaah.


Home