argb

How to create a window with a bit depth of 32

≡放荡痞女 提交于 2019-11-29 06:47:35
I'm trying to create a X11 window with a bit depth of 32 so that I can use ARGB colors. Here's what I do: XVisualInfo vinfo; int depth = 32; XMatchVisualInfo(dpy, XDefaultScreen(dpy), depth, TrueColor, &vinfo); XCreateWindow(dpy, XDefaultRootWindow(dpy), 0, 0, 150, 100, 0, depth, InputOutput, vinfo.visual, 0, NULL); Here's what happens: X Error of failed request: BadMatch (invalid parameter attributes) Major opcode of failed request: 1 (X_CreateWindow) Serial number of failed request: 7 Current serial number in output stream: 7 Any pointers on why there is a BadMatch error? Havoc P The problem

Android - Read PNG image without alpha and decode as ARGB_8888

£可爱£侵袭症+ 提交于 2019-11-29 04:36:41
I try to read an image from sdcard (in emulator) and then create a Bitmap image with the BitmapFactory.decodeByteArray method. I set the options: options.inPrefferedConfig = Bitmap.Config.ARGB_8888 options.inDither = false Then I extract the pixels into a ByteBuffer. ByteBuffer buffer = ByteBuffer.allocateDirect(width*height*4) bitmap.copyPixelsToBuffer(buffer) I use this ByteBuffer then in the JNI to convert it into RGB format and want to calculate on it. But always I get false data - I test without modifying the ByteBuffer. Only thing I do is to put it into the native method into JNI. Then

Access to raw data in ARGB_8888 Android Bitmap

烂漫一生 提交于 2019-11-28 20:52:06
I am trying to access the raw data of a Bitmap in ARGB_8888 format on Android, using the copyPixelsToBuffer and copyPixelsFromBuffer methods. However, invocation of those calls seems to always apply the alpha channel to the rgb channels. I need the raw data in a byte[] or similar (to pass through JNI; yes, I know about bitmap.h in Android 2.2, cannot use that). Here is a sample: // Create 1x1 Bitmap with alpha channel, 8 bits per channel Bitmap one = Bitmap.createBitmap(1,1,Bitmap.Config.ARGB_8888); one.setPixel(0,0,0xef234567); Log.v("?","hasAlpha() = "+Boolean.toString(one.hasAlpha())); Log

Color similarity/distance in RGBA color space

岁酱吖の 提交于 2019-11-28 17:08:54
问题 How to compute similarity between two colors in RGBA color space? (where the background color is unknown of course) I need to remap an RGBA image to a palette of RGBA colors by finding the best palette entry for each pixel in the image*. In the RGB color space the most similar color can be assumed to be the one with the smallest euclidean distance. However, this approach doesn't work in RGBA, e.g., Euclidean distance from rgba(0,0,0,0) to rgba(0,0,0,50%) is smaller than to rgba(100%,100%,100%

Trying to convert Bilinear Interpolation code from Java to C/C++ on Android

非 Y 不嫁゛ 提交于 2019-11-28 06:34:09
问题 Background I've made a tiny Android library for handling bitmaps using JNI (link here) In the long past, I've made some code of Bilinear Interpolation as a possible algorithm for scaling of images. The algorithm is a bit complex and uses pixels around to form the target pixel. The problem Even though there are no errors (no compilation errors and no runtime errors), the output image look like this (scaled the width by x2) : The code Basically the original Java code used SWT and supported only

Fast Converting RGBA to ARGB

纵饮孤独 提交于 2019-11-28 05:41:25
问题 I am trying to convert a rgba buffer into argb, is there any way to improve the next algorithm, or any other faster way to perform such operation? Taking into account that the alpha value is not important once in the argb buffer, and should always end up as 0xFF. int y, x, pixel; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { pixel = rgbaBuffer[y * width + x]; argbBuffer[(height - y - 1) * width + x] = (pixel & 0xff00ff00) | ((pixel << 16) & 0x00ff0000) | ((pixel >> 16) & 0xff);

Create a BufferedImage from file and make it TYPE_INT_ARGB

假装没事ソ 提交于 2019-11-28 04:56:15
I have a PNG file with transparency that is loaded and stored in a BufferedImage . I need this BufferedImage to be of TYPE_INT_ARGB . However, when I use getType() the returned value is 0 ( TYPE_CUSTOM ) instead of 2 ( TYPE_INT_ARGB ). This is how I load the .png : public File img = new File("imagen.png"); public BufferedImage buffImg = new BufferedImage(240, 240, BufferedImage.TYPE_INT_ARGB); try { buffImg = ImageIO.read(img ); } catch (IOException e) { } System.out.Println(buffImg.getType()); //Prints 0 instead of 2 How can I load the .png, save in the BufferedImage and make it TYPE_INT_ARGB

Android - Read PNG image without alpha and decode as ARGB_8888

本秂侑毒 提交于 2019-11-27 18:42:20
问题 I try to read an image from sdcard (in emulator) and then create a Bitmap image with the BitmapFactory.decodeByteArray method. I set the options: options.inPrefferedConfig = Bitmap.Config.ARGB_8888 options.inDither = false Then I extract the pixels into a ByteBuffer. ByteBuffer buffer = ByteBuffer.allocateDirect(width*height*4) bitmap.copyPixelsToBuffer(buffer) I use this ByteBuffer then in the JNI to convert it into RGB format and want to calculate on it. But always I get false data - I test

Transparent ARGB hex value

╄→尐↘猪︶ㄣ 提交于 2019-11-27 05:48:15
The colors in this table is all not transparent. I guess the value for the A is set to FF . What is the code for transparency? For example this color FFF0F8FF (AliceBlue), to a transparent code such as ??F0F8FF ? theHacker Transparency is controlled by the alpha channel ( AA in #AARRGGBB ). Maximal value (255 dec, FF hex) means fully opaque. Minimum value (0 dec, 00 hex) means fully transparent. Values in between are semi-transparent, i.e. the color is mixed with the background color. To get a fully transparent color set the alpha to zero. RR , GG and BB are irrelevant in this case because no

Transparent ARGB hex value

五迷三道 提交于 2019-11-26 08:39:33
问题 The colors in this table is all not transparent. I guess the value for the A is set to FF . What is the code for transparency? For example this color FFF0F8FF (AliceBlue), to a transparent code such as ??F0F8FF ? 回答1: Transparency is controlled by the alpha channel ( AA in #AARRGGBB ). Maximal value (255 dec, FF hex) means fully opaque. Minimum value (0 dec, 00 hex) means fully transparent. Values in between are semi-transparent, i.e. the color is mixed with the background color. To get a