graphics

Java Graphics2D floating point accurate drawOval alternative?

老子叫甜甜 提交于 2019-12-20 03:10:04
问题 So I am trying to draw an arc and put a circle around its round endpoint, but I am having issues due to rounding to the nearest pixel. This is visible in some but not all cases. Is there a way to draw circles using floating points and anti-aliasing to eliminate this rounding error? You can run this code to see the problem. I have drawn arcs of 0 length (appearing as large dots) instead of full arcs for clarity. import java.awt.*; import javax.swing.*; public class Example extends JFrame {

monogame screen resolution is incorrect

醉酒当歌 提交于 2019-12-20 03:09:10
问题 Monogame, or XNA really, is reporting the wrong screen resolution on my Surface Pro 3. Using GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width and Height returns dimensions of 800 x 600, which is incorrect. So, I cannot set up my game size correctly. I've been using this code without problem on an Acer V5 and can set the game resolution to a size I expect. This is because the GraphicsAdapter reports the correct screen size. Whether using it as is, or docking the tablet with an external

How to draw a string at an exact pixel position

依然范特西╮ 提交于 2019-12-20 03:07:07
问题 I try to draw a string (single character) in C# into a Bitmap at an exact position with: Bitmap bmp = new Bitmap(64, 64); Graphics g = Graphics.FromImage(bmp); g.DrawString("W", font1, new SolidBrush(myColor), new Point(32,32); There is so much empty space rendered around a single letter, that I can not guess the "needed" position to draw the character to have it at the correct position at the end. By now I have the pixel exact dimension of the character (looking at bits in a separately

Java Swing Graphical Glitches Dealing with Transparency and Images

可紊 提交于 2019-12-20 03:05:23
问题 So I have this login form and I have a "user photo." I'm trying to make it so that when you hover the mouse over the photo area, a transparent label with a colored background will appear (to give the effect of "selecting the photo"). It looks like this: And once you move your mouse off it, it goes back to being "deselected." Now my problem is, if you hover your mouse over the login button first then move your mouse over the photo, a "ghost login button" appears. It looks like this: I don't

Plot 2 tmap objects side-by-side

岁酱吖の 提交于 2019-12-20 02:46:20
问题 Example: I want to plot two tmap plots side by side, which are generated by this code. library(tmap) library(gridExtra) data(World) plot1= tm_shape(World, projection = "merc") + tm_layout("", inner.margins=c(-1.72, -2.05, -0.75, -1.56)) + tm_borders(alpha = 0.3, lwd=2) plot2= tm_shape(World, projection = "merc") + tm_layout("", inner.margins=c(-1.72, -2.05, -0.75, -1.56)) + tm_borders(alpha = 0.3, lwd=2) plot1 and plot2 work fine as single stand-alone plots: Problem: I have problems to put

When running a program using Process.Start, it can't find it's resource files

痞子三分冷 提交于 2019-12-20 02:28:11
问题 i have this code: private void button1_Click(object sender, EventArgs e) { Process p = new Process(); p.StartInfo.FileName = "C:/Users/Valy/Desktop/3dcwrelease/3dcw.exe"; p.Start(); } 3dcw.exe is an app for OpenGL graphics. The problem is that when I click on the button, the executable file runs, but it can't access its texture files. Does anyone have a solution? I think something like loading the bitmap files in the background, then running the exe file, but how can i do that? 回答1: I've

Difference between Color and SolidColorBrush clarification

一世执手 提交于 2019-12-20 01:34:07
问题 Ok this has been bugging me and I haven't really found any kind of definitive answer as the the reason/cause of the difference between Color & SolidColorBrush so I'm wondering if someone can educate me on this. I already know the differences in usage, like for example I can use a SolidColorBrush in a dependency like if I say; <SolidColorBrush x:Key="BlahBrush" Color="#FFFFFFFF"/> <Border Background="{StaticResource BlahBrush}"/> but then say I throw the same resource in an EasingColorKeyFrame

Difference between Color and SolidColorBrush clarification

我与影子孤独终老i 提交于 2019-12-20 01:34:01
问题 Ok this has been bugging me and I haven't really found any kind of definitive answer as the the reason/cause of the difference between Color & SolidColorBrush so I'm wondering if someone can educate me on this. I already know the differences in usage, like for example I can use a SolidColorBrush in a dependency like if I say; <SolidColorBrush x:Key="BlahBrush" Color="#FFFFFFFF"/> <Border Background="{StaticResource BlahBrush}"/> but then say I throw the same resource in an EasingColorKeyFrame

Draw offscreen with JOGL

守給你的承諾、 提交于 2019-12-20 01:12:23
问题 As part of a larger project I'm trying to implement a facility using JOGL that will export 3D renderings to bitmap formats. We do this by creating a GLJPanel and drawing the scene we want to it, then extracting the bitmap. This all works fine as long as the system has at least one visible window on the screen - not necessarily the window containing the panel we are drawing to. But if we try to do this without making any window visible the GLJPanel won't draw. Stepping through the JOGL source

Calculate bounding box of arbitrary pixel-based drawing

蹲街弑〆低调 提交于 2019-12-20 01:09:05
问题 Given a contiguous drawing of arbitrary pixels (e.g. on an HTML5 Canvas) is there any algorithm for finding the axis-aligned bounding box that is more efficient than simply looking at every pixel and recording the min/max x/y values? 回答1: Just scanline from top left to right and down to get y top,and similar algorithm with different directions for the rest. Edit by Phrogz: Here's a pseudo-code implementation. An included optimization ensures that each scan line does not look at pixels covered