rgb

Re: Get pixel data as array from UIImage/CGImage in swift

。_饼干妹妹 提交于 2019-12-12 03:36:17
问题 This code works for me (Swift 2 playground) in Gray scale, loading a colour .BMP image... Get pixel data as array from UIImage/CGImage in swift ... but if I change bytesPerPixel to 3 (or 4) and use let colorSpace = CGColorSpaceCreateDeviceRGB() ...the code still runs with no errors, but pixel values are all zeros. Any suggestions as to how to fix that? 回答1: You probably forgot the CGImageAlphaInfo parameter. For color images, if you assume bytesPerPixel to be 4, you need to set either RGBA

Cannot get colour of pixel on screen

淺唱寂寞╮ 提交于 2019-12-12 02:49:22
问题 I want to find the colour of a specific pixel on the screen. The background of the JFrame is set to white, which is RGB(255, 255, 255). The Graphics object is set to black, which is RGB(0, 0, 0). I draw a rectangle. (100, 100) is a pixel on the outline of the rectangle. Before drawing, I get the pixel colour of (100, 100) and it gives RGB(255, 255, 255). After drawing, I get the pixel colour of (100, 100) and it gives RGB(255, 255, 255). Is it not supposed to be RGB(0, 0, 0)? Also, the output

Hex to BGR Hex conversion for KML color in Java

若如初见. 提交于 2019-12-12 02:17:52
问题 I'm building a utility that takes placemarks on a web based map and exports them to KML for use in Google Earth. The problem is the hex values I'm given are standard RGB, whereas KML needs BGR (AABBGGRR where AA is the alpha, but that's not relevant here). For simple colors like red (FF0000), the conversion is simple: 0000FF. However, I've found for something like 7DCCFF (which is like a light blue), simply reversing the string doesn't yield the same color in Google Earth. Am I missing

Executing multiple functions/commands on Arduino

◇◆丶佛笑我妖孽 提交于 2019-12-12 01:43:08
问题 I am using an RFduino and an iOS application to control some RGB LEDs. This is how I'm sending a string command to the module: - (IBAction)fadeButtonPressed:(id)sender { [rfduino send:[@"fade" dataUsingEncoding:NSUTF8StringEncoding]]; } These command(s) are coming back just fine on the RFduino side: void RFduinoBLE_onReceive(char *data, int len) { if (strncmp(data, "fade", 4) == 0) { // begin fading chosen LED colour } } Is there a better way of executing multiple functions on Arduino? It

how can i give color name to hex color code in android

强颜欢笑 提交于 2019-12-11 20:32:56
问题 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gallery); // Find references to the GUI objects button = (Button) findViewById(R.id.button); image = (ImageView) findViewById(R.id.image); // TextView id tv_selected_colour = (TextView) findViewById(R.id.tv_color_selected); // Set button's onClick listener object. button.setOnClickListener(this); // access images using bitmap final Bitmap bitmap = ((BitmapDrawable) image

How to Compare an RGB Value to Color?

左心房为你撑大大i 提交于 2019-12-11 19:35:46
问题 I'm scanning through the pixels in a BufferedImage to see if some of the pixels are a certain color. I've tried this by doing the following: for(int x = 0; x < 16; x++) { for(int y = 0; y < 16; y++) { if(image.getRGB(x, y) == new Color(209, 167, 86).getRGB()) System.out.println("Same Color Detected!"); } } But image.getRGB() returns a different value to Color.getRGB() . How can I compare them? These are some examples of the values (first digit is from image, second the colour I'm comparing):

how generate only darken random colors in javascript?

笑着哭i 提交于 2019-12-11 19:24:38
问题 I've been reading the questions here about how to generate random colors in JS/JQuery. But I want to generate only darken colors avoiding the black, yellow and gray range colors, in order to be able to draw areas in google maps with different colors. Thanks 回答1: var hue = Math.floor(Math.random() * 360), saturation = Math.floor(Math.random() * 100), lightness = Math.floor(Math.random() * 50), color = "hsl(" + hue + ", " + saturation + "%, " + lightness + "%)"; That was to generate a random

Display double array in picturebox

落爺英雄遲暮 提交于 2019-12-11 19:19:36
问题 I need to display this array of double in picture box in C# double[,] Y1 = new double[width, height];//not empty array contain brightness from RGB R = new byte [width, height]; G = new byte [width, height]; B = new byte [width, height]; Bitmap bmp4 = new Bitmap(width, height); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Y1[x, y] = (0.39 * R[x,y]) + (0.59 * G[x,y]) + (0.12 * B[x,y]); Int32 zz = Convert.ToInt32(Y1[x, y]); bmp4.SetPixel(x, y, zz); } } pictureBox6.Image

Manipulate RGBA Javascript

风格不统一 提交于 2019-12-11 16:48:33
问题 In Javascript i have a Uint8Array() RGBA of image, here is console.log of this : Here is image with rgba array as a string in HTML: Is that possible to manipulate this array, to ex. change colors? Thanks for help! 回答1: Here's a JS algorithm of plotting a pixel to this kind of array: function changeColor(x, y, c) { colorArray[(x * 4) + (y * (imageWidth * 4))] = c.r; colorArray[(x * 4) + (y * (imageWidth * 4)) + 1] = c.g; colorArray[(x * 4) + (y * (imageWidth * 4)) + 2] = c.b; colorArray[(x * 4

How to modify color brightness in C#?

夙愿已清 提交于 2019-12-11 16:44:01
问题 In c#, you can get the HSL brightness of a color by doing Color.GetBrightness(). If I want to increase the brightness of a color by a certain percentage, I cannot simply multiply the individual RGB values by that amount. It seems HSL doesn't work like that. How would I do it? 回答1: I think this article can help you with this and all other color related questions. It has C# source for all conversions and modifications. RGB and HSL Colour Space Conversions 来源: https://stackoverflow.com/questions