rgb

C++ Getting RGB from hBitmap

南楼画角 提交于 2019-12-09 06:48:01
问题 Working with bitmaps is very new to me so I've been really struggling with the online tutorials and strategies that I've read through. Basically my goal is to scan the screen for a particular RGB value. I believe the steps to do this is to capture the screen in a hBitmap and then produce an array of RGB values from it that I can scan through. I originally started with GetPixel but that is very slow. The solution was to use GetDIBits which produces the array of RGB values. The problem is that

Finding N Distinct RGB Colors

拥有回忆 提交于 2019-12-09 05:52:45
问题 I'm trying to graphically display a graph of N lines and I'm trying to find a way to dynamically assign distinct colors based on how many lines I have. The values in RGB range from 0 to 1. I can't use white because the background is white. I found it easy for N < 7: r=(h&0x4)/4; g=(h&0x2)/2; b=h&0x1; This gives me black, blue, green, cyan, red, magenta, yellow. But after that it will use white and then loop. Does anybody know a good way to assign RGB values for an index? I also have an

For an jpg image file get 3-4 average main colors

允我心安 提交于 2019-12-09 05:45:03
问题 I would like to be able to detect the 3-4 main colors of a jpg image file. Example images and sample code below: - red, black, white - white, green, pink - blue, yellow, black I have modified some code to get the below, but still has trouble grouping colors. public static int RoundColorToGroup(int i) { int r = ((int)Math.Round(i / 10.0)) * 10; if (r > 255) r = 255; return r; } [TestMethod] public void AverageColorTest_WebExample() { Bitmap bm = new Bitmap("C:\\Users\\XXXX\\Desktop\\example1

How do I set the R, G, B and Alpha components of a color?

爷,独闯天下 提交于 2019-12-09 02:53:33
问题 There are 3 integer values that makes up a RGB value, and also i have the Alpha component value of the color. how do i set these 4 values to get the desired colour 回答1: You can create a Color object (the values should either be ints between 0 - 255 or floats between 0f - 1f : Color c = new Color(red, green, blue, alpha); If you want to paint an image with that color: BufferedImage image = new BufferedImage(300, 200, BufferedImage.TYPE_INT_ARGB); Graphics graphics = image.getGraphics();

How to display a raw YUV frame in a Cocoa OpenGL program

99封情书 提交于 2019-12-09 01:47:53
问题 I have been assigned wit the task to write a program that takes a sample raw YUV file and display it in a Cocoa OpenGL program. I am an intern at my job and I have little or no clue how to start. I have been reading wikipedia & articles on YUV, but I couldn't find any good source code on how to open a raw YUV file, extract the data and convert it into RGB and display it in the view window. Essentially, I need help with the following aspects of the task -how to extract the YUV data from the

Get RGB value from screen pixels with python

江枫思渺然 提交于 2019-12-09 01:02:23
问题 To get the RGB values from a pixel of the screen with coordinates (x,y) in Python, I do: import PIL.ImageGrab rgb = PIL.ImageGrab.grab().load()[x,y] It was working as I expected until I did: rgb = PIL.ImageGrab.grab().load()[1673,0] Instead of the RGB values of the pixel, I received: IndexError: image index out of range I don't understand why because my screen has 1920x1080 resolution. How can I fix this? 回答1: If you do: import PIL.ImageGrab PIL.ImageGrab.grab().size You will see the

On iOS how to quickly convert RGB24 to BGR24?

无人久伴 提交于 2019-12-08 17:54:38
问题 I use vImageConvert_RGB888toPlanar8 and vImageConvert_Planar8toRGB888 from Accelerate.framework to convert RGB24 to BGR24, but when the data need to transform is very big, such as 3M or 4M, the time need to spend on this is about 10ms. So some one know some fast enough idea?.My code like this: - (void)transformRGBToBGR:(const UInt8 *)pict{ rgb.data = (void *)pict; vImage_Error error = vImageConvert_RGB888toPlanar8(&rgb,&red,&green,&blue,kvImageNoFlags); if (error != kvImageNoError) { NSLog(@

Converting RGB to HLS and back

纵然是瞬间 提交于 2019-12-08 17:48:51
问题 I'm using python's colorsys library to convert RGB color values to HLS. Just to verify, I tried converting back to RGB and got a different value back. I can understand minor differences because of precision issues, but these values are significantly different. Here's my code: import colorsys r=192 g=64 b=1 hlsval = colorsys.rgb_to_hls(r,g,b) rgbval=colorsys.hls_to_rgb(hlsval[0],hlsval[1],hlsval[2]) print hlsval, rgbval Output: (0.16666666666666666, 96.5, -1.0) (191.99999999999994, 192.0, 1.0)

How to perform RGB->YUV conversion with ActionScript?

≡放荡痞女 提交于 2019-12-08 11:54:25
问题 How to perform RGB->YUV conversion with ActionScript? Libs? Tuts? Articles? 回答1: Check this article: http://www.fourcc.org/fccyvrgb.php Conversion is quite easy so you probably could write your own function based on this: Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16 Cr = V = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128 Cb = U = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128 来源: https://stackoverflow.com/questions/1737712/how-to-perform-rgb-yuv-conversion-with-actionscript

Checking if a color is in a specific range of colors

和自甴很熟 提交于 2019-12-08 08:17:34
问题 How would you check if a rgb or hex value is within a specific range of colors? Preferably with ruby. I'm using ruby and rmagick to extract colors (quantize and color_histogram) from images and then store those colors in the database. If someone searched for a color(hex or rgb) that is similar I want to be able to return that color. e.g. If someone searched for #f4f4f4 I'd like to return #f5f5f5, #f3f3f3, and all the other close hex values. 回答1: If you treat RGB as a three-dimensional space