graphics

How can I implement java.awt.Composite efficiently?

无人久伴 提交于 2020-01-01 09:22:29
问题 Background: I need to be able to create imagery in "disabled" look. The commonly suggested approach is to convert images to grayscale and show the grayscaled image. The drawback is that it only works with images, making it cumbersome to show graphics where you do not have immediate access to an image in disabled state. Now I thought this could be done on the fly with java.awt.Composite (and then I would not need to know how for example an Icon is implemented to render it disabled). Only there

How can I get a collection of all the colors in System.Drawing.Color?

人盡茶涼 提交于 2020-01-01 09:08:23
问题 How can I extract the list of colors in the System.Drawing.Color struct into a collection or array? Is there a more efficient way of getting a collection of colors than using this struct as a base? 回答1: So you'd do: string[] colors = Enum.GetNames(typeof(System.Drawing.KnownColor)); ... to get an array of all the collors. Or... You could use reflection to just get the colors. KnownColors includes items like "Menu", the color of the system menus, etc. this might not be what you desired. So, to

How to get the bitmap/image from a Graphics object in C#?

六眼飞鱼酱① 提交于 2020-01-01 08:38:14
问题 I want to know what the intermediate state of the buffer where the Graphics object is drawing some stuff. How do I get hold of the bitmap or the image that it is drawing on? 回答1: I'm not really sure if I understand what you're asking for, as your question is very unclear. If you want to know how to save the contents of a Graphics object to a bitmap, then the answer is that there's no direct approach for doing so. Drawing on a Graphics object is a one-way operation. The better option is to

What is a pixel (px) in CSS?

元气小坏坏 提交于 2020-01-01 08:18:22
问题 I am reading an ASP.NET book and it refers to CSS files and talks about pixels. But I never understood it from a resolution, layout, etc. point of view. For example, what does the following mean in CSS file definition? #header { padding: 0px; margin: 0px; } 回答1: This is a little beyond where you might be at the moment, but a CSS pixel is not necessarily exactly the same size as a single pixel on your display. According to the spec: If the pixel density of the output device is very different

What is a pixel (px) in CSS?

放肆的年华 提交于 2020-01-01 08:18:18
问题 I am reading an ASP.NET book and it refers to CSS files and talks about pixels. But I never understood it from a resolution, layout, etc. point of view. For example, what does the following mean in CSS file definition? #header { padding: 0px; margin: 0px; } 回答1: This is a little beyond where you might be at the moment, but a CSS pixel is not necessarily exactly the same size as a single pixel on your display. According to the spec: If the pixel density of the output device is very different

Search for similar images with different filenames in two directories

假装没事ソ 提交于 2020-01-01 07:28:09
问题 I have 2 directories with lots and lots of images, say: color/ and gray/ . In color/ images are named: image1.png image2.png, etc. I know that gray/ contains the same images, but in gray-scale, and the file names and order of files is different (eg: file_01.png, but this IS NOT the same image as image1.png). Is it possible to make a comparison of images in both directories and copy color/ files to a results / directory with gray/ file names? Example: directory | directory | directory "color/"

Is it possible generate normal map from heightmap texture from math point of view?

回眸只為那壹抹淺笑 提交于 2020-01-01 07:21:30
问题 My view is that you can not generate normal map only from height map texture? Am I right or not? Math Arguments: Assume that surface is given a continuous bijection from S = [0,1] T = [0,1] Let's call SxT as image space. It can be proved from differentional geometry that normal to that parametric surface is If assume that mapping from SxT image space to geometric euclidian space is very simple then we can retrive: Then you can calculate such partial derivatives with some difference scheme. We

Merging and splitting overlapping rectangles to produce non-overlapping ones

余生长醉 提交于 2020-01-01 07:02:29
问题 I am looking for an algorithm as follows: Given a set of possibly overlapping rectangles (All of which are "not rotated", can be uniformly represented as (left,top,right,bottom) tuplets, etc...), it returns a minimal set of (non-rotated) non-overlapping rectangles, that occupy the same area. It seems simple enough at first glance, but prooves to be tricky (at least to be done efficiently). Are there some known methods for this/ideas/pointers? Methods for not necessarily minimal, but

Anti aliasing DrawLine on CE

心不动则不痛 提交于 2020-01-01 06:28:27
问题 I am drawing a line to a Graphics object in Windows CE using C#.NET 3.5. The code I am using looks like this: e.Graphics.DrawLine(new Pen(Color.FromArgb(11, 118, 200), 2), x1, y1, x2, y2); This works however looks terrible due to jaggies etc. Is there anyway I can draw anti aliased lines? From what I can tell the Graphics object doesn't support this natively but is there anyway to "cheat" this effect using some trickery? 回答1: A fast trick if you're drawing on a solid color background, you can

Does OpenGL use Xlib to draw windows and render things, or is it the other way around?

杀马特。学长 韩版系。学妹 提交于 2020-01-01 05:36:08
问题 I want to render fonts and lines on a window using either OpenGL or Xlib , but I'd like to know which one is "more fundamental". Using the Xlib interface I can render such things with something like this (which I found here): // gcc x_1.c -o x_1 -lX11 && ./x_1 #include <stdio.h> #include <X11/Xlib.h> // This program draws a red line and some text in a chosen font. Display *display; Window window; XSetWindowAttributes attributes; XGCValues gr_values; XFontStruct *fontinfo; GC gr_context;