English proverbs have a saying: "A picture is worth a thousand words (a picture is worth a thousand words)," mean when we use to describe the image will help viewers understand more quickly if we just say it.
Please restart the program and then hold the bar of 3 VScrolls pull up, pull down to see results. The program window looks like this:
Visual Basic 6 can give us some means of graphics (graphics) to make up for the windows rich, friendly, easy to work with, and interesting. Whether that means the municipality is not fast enough for me to write game programs (games), but relatively well equipped to meet the common needs.
When it comes to graphics, we want to distinguish it from ordinary text. For example we use Notepad to edit a poem in a window. While the poem is being displayed can be changed easily by using the keyboard to type a new word to add, use the button Delete , Backspace for deleting text. That we did with text .
Now, while still displaying the poem, we use a program such as Graphic Capture PhotoImpact by Ulead to capture the image of the poem window (active window) look like a photo, then we have a Graphic . Then, to amend the poem from this graphic we have to use a graphic editor such as MSPaint, PaintShopPro . etc. The letters in the picture has the same graphic format as we see a photo, edit, and want to use a brush with paint.
Below is a graphic of a Notepad window after adding the text g and a question mark at the end by using MSPaint.
Màu (color) và độ mịn (resolution)
We say a good picture because it is sharp and clear color. Do you remember the opening ceremony on the Moscow Olympics, where they show great many by asking the audience, in a rectangular area, each held up a cardboard cut-sheet color. Thousands put up cardboard cut panels assembled into a beautiful picture.
A graphic of Windows also includes lots of little spots, each spot is called a pixel , capable of displaying 16, 256, ... different colors.Độ mịn (resolution)
Ordinary fineness (resolution) of the screen we use is 800x600, ie has 800 pixels horizontally and 600 pixels height. After this, the better to see the fineness are used to cut SuperVGA and 1028x768 Monitor possible. I have to say cutter SuperVGA 2MB RAM, why would you need to display graphic 2MB beautiful?
If the color of each pixel is represented by a data byte is a byte can contain a number from 0 to 255.People agree on a convention that the number 0 represents black, 255 represents the number of such white. If the fineness of the screen is 1024x768, then we will need 1024x768 = 786,432 bytes, which is almost 0.8 MB.
A byte is 8 bits. Sometimes we hear 16 bit color, instead referring a byte, we use two bytes for each pixel.Thus each pixel is capable of displaying 2 16 = 65,536 different colors. Want to use 16 bit color for SuperVGA, we need to have 1024x768x2 = 1,572,864 bytes, which is almost 1.6 MB. That is why we need 2MB of RAM. Note that the VGA RAM (Vector Graphics Adapter) card is not to do with computer's RAM memory.
No doubt the Angkor Le ancient instruments known Informatics should say: "A picture is worth a thousand words." Text word consists of 4 bytes time IBM, the screen is worth a thousand words 400, so the tools are not very accurate, but regarded as true.
Remember that with a graphic display on two screens with the same fineness, such as 800x600, but different sizes, such as 14 inches and 17 inches, then of course the screen will be larger than 17 inches, but it still has the same number of pixels, a pixel of the pixel is greater than 14 inches of screen.
In other words, if we use a larger screen, the graphic will be bigger but it does not mean better. Want to see more clearly, we must make the graphic has a higher fineness. Back story Moscow Olympics, wants better pictures, then in the same area, we had to ask her children to sit together around land and contains more people each holding a sheet of cardboard cut-smaller .
I change the Display Properties of a screen by right clicking the desktop and select Properties , then click the Tab Settings and then select Screen resolution and Color quality is like this:
When we increase the fineness of the screen, the image will be small because the pixel size is scaled.Therefore, we can show more things on the desktop. Quality of the graphic remains unchanged, although the smaller. Remember when they wanted a better image composition, and contains graphic, we must use a high fineness. Like shooting, we need something nice to the camera using a professional film of great depth and focus, instead of using automatic machines cheap, just put up a press shoot.Màu (color)
When we use only one bit (only values 0 or 1) for each pixel, we only have white or black. Meantime, you can use a byte (8 bits) to 8 pixels. Nevertheless, if high enough fineness of the graphic, the picture is beautiful. Try black and white photos of the marvels of the High Dam, High Scope is known. Fax machines use the principle of scanning A4 size paper into the black and white pixels and then sent via telephone lines through the other end to reconstruct the image from the data pixels.
Visual Basic 6 gives us a number assigned to each color VB can display, or directly select a color from Dialog. There are four ways:
- You assign a number directly or select a color from the palette.
- You select one of the predefined constants in VB, called intrinsic color constants (intrinsic meaning is basically home-grown or in-built), such as vbRed, vbBlue . List of color constants obtained from intrinsic VB6 online help are listed below:
This image has been resized in order to avoid breaking the interface. Click here to view photo in full size (580x273) - Use QBColor Function to select one of 16 colors. QBColor function derived from Quick Basic (QBasic) of Microsoft. QBsic is a precursor to Visual Basic. In QBasic you can use the numbers 1,2,3 .. to specify the color Blue, Green, Cyan,. vv.Function QBColor simplified use of color, the user need not worry about mixing three basic colors Red, Green, Blue. You simply write code like:
Here are the numbers of colors can be used with Function QBColor.
Value Color Value Color 0 Black 8 Gray 1 Blue 9 Light Blue 2 Green 10 Light Green 3 Cyan 11 Light Cyan 4 Red 12 Light Red 5 Magenta 13 Light Magenta 6 Yellow 14 Light Yellow 7 White 15 Bright White - Dung RGB Function để Tron Do Mau R ed, G reen va B lue. Trong cai ke Cac Liet have intrinsic color constants phía train, neu ban y se để thấy vbWhite (0xFFFFFF) la cua Tong so vbRed (0x0000FF), vbGreen (0x00FF00) va vbBlue (0xFF0000). MOT Mau được biểu to Dien cua su PHA Tron Do Thanh Phan Mau CAN ban, there Mau Moi tri co mot so tu byte 0 đến 255.0 MAU is Dung khong la, 255 la DJA Mau Dung Toi is.
Number system we use every day is decimal. VbRed 0xFF value of the number 255 written in hexadecimal format (Hexadecimal, or hex for short and here is marked with 0x before the number to distinguish the decimal number). Hex numbers in our counting system from 0 to 9 and A, B, C, D, E, F and the number of hexadecimal 10, 11, .., 19, 1A, 1B, .. 1E, 1F, 20, 21 .. etc. That is, instead of using 10 symbols from 0 to 9 in decimal, we use 16 symbols from 0 to F.To learn more about the Hex system, please read the binary number .
In the picture below is an example shows that blue light was composed of three components selected Blue (0x990000 = 153 * 256 * 256), Green (0xCC00 = 204 * 256) and Red (0xFF = 255):Note: You can use the Windows Calculator to transfer numbers between Decimal format, Binary and Hexadecimal. Select View | Scientific instead View | Standard .Function RGB
Function to apply the RGB, we'll write a VB6 program. Please start a new VB6 program, put in a Label named Label1 Caption with Red and Vertical Scroll a name VScroll1 . Then select both Label1 and then Copy and Paste VScroll1 twice to the two pairs. Change Label Caption of this new two-out Green and Blue . We now have a three-Vertical Array VScroll1 Scrolls same name, the index is 0.1 and 2.
Place a PictureBox named picColor VScrolls three to the right. Add a Label the bottom, name itlblRGBValue , caption clear memory of it, do not have to Label1 text below:Now select all three VScrolls and edit value of property in the Properties window to the Max 255, you say when you pull the bar up and down it's a VScroll1 limit its value from the Min is 0 and Max is 255.
This image has been resized in order to avoid breaking the interface. Click here to view photo in full size (514x513)
The main thing we have to do is write code to handle the Event Change of VScrolls. Because we are an Array so you can use a single Sub to handle events from all three VScrolls. Each time a change in the 3 VScrolls values will blend the three colors Red, Green, Blue values represented by the color of 3 VScrolls BackColor of the PictureBox picColor . At the same time showing us the value of the three color components Red, Green and Blue Label lblRGBValue . Please double click on one of three VScrolls to write code as follows:
This image has been resized in order to avoid breaking the interface. Click here to view photo in full size (733x429)
Private Sub VScroll1_Change(Index As Integer) ' Use Function RGB to mix 3 colors VScroll1(0) for Red, ' VScroll1(1) for Green and VScroll1(2) for Blue ' and assign the result to BackColor of PictureBox picColor picColor.BackColor = RGB(VScroll1(0).Value, VScroll1(1).Value, VScroll1(2).Value) ' Variable used to prepare display string Dim strRGB As String ' Description of what is displayed strRGB = "picColor.BackColor = RGB(Red, Green, Blue) " & vbCrLf ' Values of Red, Green, Blue in Decimal strRGB = strRGB & " Decimal: " & VScroll1(0).Value & ", " & VScroll1(1).Value & ", " & VScroll1(2).Value & vbCrLf ' Values of Red, Green, Blue in Hexadecimal strRGB = strRGB & " Hex: 0x" & Hex(VScroll1(0).Value) & ", 0x" & Hex(VScroll1(1).Value) & ", 0x" & Hex(VScroll1(2).Value) ' Assign the resultant string to caption of Label lblRGBValue lblRGBValue.Caption = strRGB End Sub
You can download the source code of this program VScrollColor here.
Color Mapping
If using Hex Calculator 0xFFFFFF change the decimal number will be 16,777,215, including the number 0 if we will have a total of 16,777,216 colors. We discussed earlier 8bit (1 byte) and 16bit (2 bytes) color, but here we talk three color bytes. Such screens can not afford to provide all the calculate the RGB color function. So VGA card will do?For example, a cut VGA only supports up to 8 bits. It will provide 256 different colors. If the function requires an RGB color VGA card can provide accurate, well, if not it will seek to use two or three spots to blend the colors together and gives us the illusion we want color. This work is called the Color Mapping and the color is made is called the custom color .
Dùng Intrinsic Color Constants
One of the features of our MSWindows is to select the Color Scheme for Windows preferences. Normally, Windows is the Blue Color Scheme, but we can choose Silver Olive Green or, if you want.Only hardship if we had used a deep red to show the beautiful things in the VB6 program that is now the natural user changes Olive Green Color Scheme to make such a deep red as he did not look like anyone in the Color new Scheme.
To avoid that, instead of speaking out is what color (blue or red) color say vbActiveTitlebar or vbDesktop . etc.
Color Constant use will ensure intrinsic colors we use will be under the Color Scheme change that user to select a color from the case became not just one. As designed, we can also choose from Tab intrinsic Constant Color System when selecting colors.
To avoid that, instead of speaking out is what color (blue or red) color say vbActiveTitlebar or vbDesktop . etc.
Color Constant use will ensure intrinsic colors we use will be under the Color Scheme change that user to select a color from the case became not just one. As designed, we can also choose from Tab intrinsic Constant Color System when selecting colors.
Graphic files
When a graphic is stored in digital form with their color pixels as mentioned above, we call a Bit Map file name and its extension in the disk with BMP example House.bmp . Storage and these need lots of memory is very inconvenient to send or display on a Web page. Thus, people use these techniques to reduce memory needed to store graphic but still maintain the quality of the image. There are two types of graphic files are very common on the Web, with extensions is called JPG and GIF . Especially with GIF files can contain both animation (animation), that is a GIF file can contain multiple pictures (called frames) so that they alternately displayed in turn, the viewer feels an object is di action.(Collected)
0 comments:
Post a Comment