Groups | Blog | Home
all groups > dotnet drawing api > november 2007 >

dotnet drawing api : What site contains the OctreeQuantizer code you'd recommend


Academia
11/30/2007 8:54:08 PM
Once I saw an implementation of OctreeQuantizer that did not require the
Unsafe keyword.

Now that I want it I can't find it.

Do you know how to find that site?

Also do you have a comment about reasons for using the "safe" or the
"unsafe" OctreeQuantizer code.



What site contains the code you'd recommend?





Thanks







Academia
12/1/2007 10:38:43 AM
I got it.

What's the down side of unsafe code for a Windows application?

Thanks

[quoted text, click to view]

Bob Powell [MVP]
12/1/2007 12:57:23 PM
The article has been moved or deleted from MSDN. I wish those guys would
learn to keep reference links constant!

Here is another article on the same subject:
http://msdn2.microsoft.com/en-us/library/aa479306.aspx

The reason for using unsafe code in any graphics application is of course
speed. Direct access to memory via a pointer is guaranteed to be faster than
any other method and optimization of graphics processing is important.


--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


[quoted text, click to view]
Bob Powell [MVP]
12/2/2007 2:09:26 AM
In my opinion, the only possible downside to unsafe code is that the
requirement to understand the physical layout in memory of an object or data
structure is still of paramount importance whereas safe code takes that
responsibility away from the programmer and lightens the load.

For an old C++ programmer like me it's a useful and fast tool.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


[quoted text, click to view]
Academia
12/2/2007 9:57:55 AM
I kind of guessed that maybe the user might need more Windows privileges or
something.
Thanks, that's good to know.


[quoted text, click to view]

Frank Hileman
12/4/2007 6:25:18 AM
Hi Bob,

I guess you know pointers are not always guaranteed to be faster. Bounds
checks can be removed by the JIT compiler in some cases, and I was surprised
to find some low level rendering code was about equal in speed accessing
memory directly using pointers, or using an array of unsigned integers (4
bytes per pixel). Byte arrays are not especially fast using the CLR, but for
4 byte size elements, arrays are about as fast as pointer access. The
primary thing to avoid is marshalling data.

Regards,
Frank Hileman

check out VG.net: http://www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio graphics editor

[quoted text, click to view]

Bob Powell [MVP]
12/8/2007 1:05:23 PM
Hi Frank,
You're definitely right about the chunk size. Actually images are aligned on
four byte boundaries for just this reason. Thanks for pointing this out.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


[quoted text, click to view]
AddThis Social Bookmark Button