Blinking characters on Intel 8086 - vga

I'm working on drawing some shapes directly using the graphics card without interrupts for Intel 8086 (TASM) and I read that the 7th bit in the byte responsible for background and foreground colours can make the characters blink.
How can I set it, though, while the colours themselves are indexed 0-15 and I have only 1 byte? I mean: I can set the colour byte to 1eh so that I have a yellow char on blue background. How can I squeeze the information about the desired blinking in there?

How can I set [the 7th bit], though, while the colours themselves are indexed 0-15 and I have only 1 byte?
It's actually bit 7, not the 7th bit (those two are not the same). The mask for bit 7 is 80h (or 128 decimal), so to set a green color with blinking on you'd use an attribute of 82h, for blinking magenta it would be 85h, and so on.

Related

Targa image – damaged red and green channels

I've a problem with 16-bit targa file. I'm opening image and it colors are weird. It's problem with red and green channels – blue is fine.
How I can repair targa image, to look like on example? (first is original image, second is as must look.)
Image
EDIT: this answer gives results that look right, but won't be bit-identical to the original. Something weirder is going on.
You can make your corrupted image out of your original image by subjecting the red and green channels to a function that doubles the value, subject to wraparound:
F(r) = (r*2) % 255
F(g) = (g*2) % 255
These functions are not invertible, because more than one input value can map to the same output value. In particular,
F^-1(r) = {r / 2, r / 2 + 128}
But we can still try to recover the image if we're willing to tolerate some errors. We'll try to guess whether red (or green) should be high; if so, add 128.
Two pieces of information can guide our guess:
Is the blue channel high? Unless images contain strongly blue pixels, this is a hint that the red and green channels should be high, too.
Is there an adjacent pixel whose red (or green) channel is high, while this pixel's red channel is very low (say, less than 64)? This may suggest that both pixels are relatively bright, but this pixel's red channel got wrapped.
I recovered something very close to your original image using just the blue channel information to decide between r / 2 and r / 2 + 128, though it would probably be better using the neighboring pixels' red and green channels as well.
As a side note, one way this sort of problem could occur is if there were originally (say) 6 bits of red information, but only the least significant 5 bits were retained when the file was written. It would be useful to look at how these images were acquired to make sure that you're not chopping off the most significant bits of your R and G channels somehow.

How to create black and white 1 bit per pixel bitmap from component and print it to zebra printer?

I am writing simple application to print label with Zebra programming language ZPL and Flex. At current stage i want to print graphics and text as graphic. So the steps i need to perform is:
Capture BitmapData (black and white 1 bit per pixel) from spark
component like Label, for example. I think that i have to use BitmapData.draw
function, but i dont know how to make it black and white and 1 bit
per pixel;
Represent data in ASCII hexadecimal string.( For example 32x32 px
black rectangle will look like this
~DG000.GRF,00512,008,
,:::::::::::H07FLF80,:::::::::::::::::::::::::::::::,:::::::::::::::::::
*part of label design, exported by official Zebra Designer label editor)
where ~DG - Command to download graphic;
000.GRF - File Name and extension;
00512 - total number of bytes in graphic;
008 - number of bytes per row;
rest - is The data string defines the image and is an ASCII hexadecimal representation of the image. Each character represents a horizontal nibble of four dots.
I found an answer to step 2 using C# in following post -
How to generate a dynamic GRF image to ZPL ZEBRA print
I need about the same but written in ActionScript.
Thank You.
You are unable to make a BitmapData be 1 bit per pixel, instead you query it pixel by pixel by using getPixel() and check if it's dark enough to be called "black", if yes, act as if this "bit" is 0.

Finding close colors of a given color

I´d like to know, how, through actionscript 3, to get an array of ARGB (hexadecimal) colors, that is close to a given color.
Example:
0xFF00FF00
A green.
How to get variations of green?
I´m trying to get some green colors of a bitmapdata.
I´ve tried to get it by making a loop getting the colors using getPixels32.
The problem is, I think the bits colors of each position are different from the bits of the bitmap rendered.
It´s for a pathfinder.
Each green bit sets a node in a map, as walkable.
So I need to know what are these colors to set it as walkable for the pathfinder.
Any suggestions?
RGB space is terrible for interpreting whether colors are similar to one another. A different color space that matches closer to human perception of color is HSV (hue saturation and value). Here are the steps you should follow:
Convert your value from RGB space to HSV (http://www.cs.rit.edu/~ncs/color/t_convert.html)
Modify the saturation and value to obtain different shades of the same green hue.
You can even modify the hue a little with a defined tolerance level you specify
Reconvert back to HSV to RGB
I believe technically..one color space is smaller than the other, meaning it is not always a 1:1 conversion - but it should serve your purpose.

Random Non-White Colors That Look Okay As Background for Black Text

I'd like to generate random, non-white colors using hue, saturation and brightness that can be used as a background for black text. I've created a generator for random colors, but when I scan the numbers, I can't see any clear pattern in the colors that look too dark.
How can I generate random non-white background colors for black text? Feel free to answer with code or pseudo-code, but it's definitely not necessary.
Only generate colors with high brightness values - for example, if you were using the range 0-255 for each of {H,S,V}, you'd generate H in [0,255], S in [0,255], V in [168,255]. That should give you colors that are bright enough. You may want to restrict saturation as well (e.g. S in [0,192]), since black on full-bright, full-saturation colors may not be very readable.
You'll probably need to play with the values to get ranges that will give you usable colors.
I don't know color theory, but you can try randomly generating the 3 components in RGB (xxx,xxx,xxx) in a way that the sum of the components is greater than X (X depends of the contrast you want), and the convert to HSB.
HSV and HSL are broken models than have nothing to do with perception. You should generate your colors in YUV space (also known as YCbCr) where the intensity (Y) channel is not simply R+G+B but rather models the perceptual intensities of red, green, and blue. A good starting point would be to try random Y values at least 200 and random U and V values between -50 and 50.

Intuitive way of understanding hexadecimal html color codes?

Is there an intuitive way, or a good mnemonic, for understanding the correspondence between colors and their hexadecimal values?
You just have to remember that the scale is 00 (no color effect) through FF (full color effect) and the three parts of the triplet are red, green and blue.
000000 is black (i.e., no color) and FFFFFF is white (mixing all three primary colors).
The hard bit is remembering the mixtures, which I use the following mnemonics for:
Really good yams: Red + Green = Yellow (potatoes are my favorite food).
Really bad prunes: Red + Blue = Purple (I really hate prunes).
Good/bad apples: Green + Blue = Aqua (I'm indifferent about apples).
Obviously, you may have to come up with your own mnemonics if you food tastes differ from mine. But I find that's the easiest way for me.
Then it's just a matter of varying the quantities to add a little more red or little less blue and so on. I generally only use values of 00, 40, 80, C0 and FF since that gives you a 125-color palette to choose from and I don't want an abundance of choices to slow me down.
You need to get your head around three distinct things here.
Reading and writing numbers in hexadecimal. This just takes practice and familiarizing yourself with it. Color codes range from 00 (zero) through FF (= 255), so spend a little time (using calc.exe in Scientific mode, maybe?) picking a number and trying to guess what it'll be in hex, and vice versa. Counting in decimal is probably second nature to you; counting in hex is the same concept, with different symbols and rules.
How to read an RGB colour code as three component values. RGB codes are either written as three digits (#FFF) or six (#FFFFFF). In the first case, each digit is a single colour component; red, green, then blue. 0 = empty, F = 'full' (maximum). The second is the same but the additional digit gives you a much wider range of tones because you have 256 possible intensities for each component instead of 16.
Knowing the RGB colour model. Your primary colours are red, green and blue. Your secondary colours are yellow (R+G), magenta (R+B) and cyan (G+B). Increasing all the values makes the colour lighter; decreasing them all makes it darker. Pure greyscales will have three equal components - e.g. #ddd, #222. Tint greys by nudging one of the colour values up a bit - #866 will give you a dark grey with a hint of red. This bit you just have to learn through experience. Play with it. Get a tool like Instant Eyedropper and use it to find the hex values of known colours.
Getting it exactly right is very, very hard, but it won't take more than a couple of days before you can say "right... I want orange, which is somewhere between red (#F00) and yellow (#FF0) on the colour wheel, so let's try splitting the difference and use #F90... hmm, bit dark, so let's nudge the G and B components up a bit... #FA2... got it!"
Just think of it as mixing paint.
There are the three components RR, GG, BB, (RRGGBB) which can be mixed with different strengths. Remember that 00 is lowest strength, and ff is highest.
For example, we know that 000000 will be low strength on all colors and will be black. Likewise, ffffff is highest on all three color components, and will be white.
You can add or remove color by making one part stronger or weaker. For example, start with black 000000, and add a little red as 330000, or add a little blue with 000033. Add both and see what happens 330033.
Add a LOT of red, with ff0000. Or add a medium amount of green for 006600.
If all three components are close to the same strength, they cancel each other out and you have grayscale, which will be light or dark depending on the strength of the colors. So 000000, 333333, 666666, 999999, and ffffff are black, dark greys, ligher grays, and white.
If you take a medium gray, and add a little blue, you end up with a bluish grey, like 888899. Red, green, and blue almost equal, so almost grey, but with a bit more blue. You can experiment with them a bit.
One really great tool for viewing color codes is this (small and free):
http://www.nattyware.com/pixie.html
Hope that helps!
I'm not sure what you mean, but I always remember that it is an RGB colour: The first two digits are for red, the second pair is for green and the las ones are for blue.
like this: #RRGGBB
And of course trying to remember that lower numbers give darker coulours.
If you are looking for some way to remember the colour code for orange, I'm afraid you are out of luck. I always need to look that one up...
Hexadecimal colours are of the form #RRGGBB where RR is red, GG is green and BB is blue. Since they're hexadecimal they range from 00-FF. It should be fairly easy from that to gauge roughly what kind of colour you're dealing with for example #FF12A3 is going to be fairly red.
Break the colour up into a triplet of values that represent red, green and blue. The higher the hex value in each segment then the more of that colour there is. So #000000 is black, #FF0000 is all red, #FF00FF is purple etc.
I think it's useful to get a good HTML color chart and keep it by your desk. I like the Visibone mouse pads and posters.
Remember:
1) The order of the hex-pairs are Red, Green and Blue. This is easy to remember since we aften talk about RGB-color, RGB screens and so on.
2) The numbers should interpreted as the amount of light in the color. So 00 is no light, while FF is maximum light in that color.
3) I all three colors are of the same level, they "cancel each other out", so we get a greyscale color. 00 is minimum light, så if all three colors are 00 we get no light - ie. black. If all three colors are max-light (#FFFFFF) we get white, Any number in between is grey.
Well, monitors use an 'RGB' colorscheme. The order of the colors in the hexadecimal number is RRGGBB. So just remembering the name of the colorscheme tells you what goes where. Then you can parse the #RRGGBB as three numbers RR, GG and BB.
The higher the number the brighter that particular component.
Then you just need to remember the additive color wheel from grade school. ;)
I manage to create colors intuitively now (with some trial and error, of course), having practiced them a lot. Playing/using color mixers (with red/green/blue sliders for example) helps in understanding relationships. Now, I know that FFFF00 is yellow, FF00FF is magenta, 00FFFF is cyan, plus of course primary colors, and all others colors are in between.