Sunteți pe pagina 1din 1

Pure VB Pixel Routines First, lets discuss the basics of per-pixel graphics programming using only built-in Visual

Basic functions. I recommend that even hardened VB veterans glance through this document, as it provides the foundation for the advanced graphics principles discussed in the next three tutorials. We will discuss the only VB per-pixel graphics functions (Point and PSet), and after this is done you may know a lot more than you ever wanted to about VB graphics :) *hehe* Most of you have probably heard of the horrible twins of PSet and Point*. These two routines are usually the first per-pixel methods introduced to VB programmers (since they come included as part of the language), but perhaps inevitably they are also the slowest way to do things. Avoid ever using these routines for per-pixel image processing (though they do have some uses in non-pixel-sized work). I include them here only for completeness; I would never recommend using them in an actual image processing program because they are so extremely slow. Why are they so slow? Well discuss that later, after weve looked at their syntax.

Dim Color as Long Color = PictureBox.Point(x,y) Public Function ExtractR(ByVal CurrentColor As Long) As Byte ExtractR = CurrentColor And 255 End Function Public Function ExtractG(ByVal CurrentColor As Long) As Byte ExtractG = (CurrentColor \ 256) And 255 End Function Public Function ExtractB(ByVal CurrentColor As Long) As Byte ExtractB = (CurrentColor \ 65536) And 255 End Function

Dim R as Byte, G as Byte, B as Byte Dim Color as Long Color = PictureBox.Point(0, 0) R = ExtractR(Color) G = ExtractG(Color) B = ExtractB(Color)

PictureBox.PSet (x,y), Color

S-ar putea să vă placă și