graphics

How interfacing with graphics card work with C or C++?

五迷三道 提交于 2019-12-17 21:51:13
问题 Libraries such as OpenGL access the graphics card and can produce graphics programs, how does these libraries access the graphics card since they are implemented using C. According to what i've heard, C and C++ do not provide graphics features built in the language and producing graphics requires libraries. How then are these libraries written in C? The same question applies for sound also? Are additional features to C/C++ languages such as graphics, sound, internet access written in lower

Punch a hole in a rectangle overlay with HW acceleration enabled on View

ぐ巨炮叔叔 提交于 2019-12-17 21:45:47
问题 I have a view which does some basic drawing. After this I want to draw a rectangle with a hole punched in so that only a region of the previous drawing is visible. And I'd like to do this with hardware acceleration enabled for my view for best performance. Currently I have two methods that work, but only works when disabled hardware acceleration and the other is too slow. Method 1: SW Acceleration (Slow) final int saveCount = canvas.save(); // Clip out a circle. circle.reset(); circle

How to crop a section of an Image at cursor position?

大憨熊 提交于 2019-12-17 21:34:51
问题 I am following the link to get the image cropped and rounded. However it does not work the way I want. I spent some time but did not understand where to fix the code to get what I want. public Image CropToCircle(Image srcImage, PointF center, float radius, Color backGround) { Image dstImage = new Bitmap((int)Math.Round(Math.Ceiling(radius*2)), (int)Math.Round(Math.Ceiling(radius*2)), srcImage.PixelFormat); using (Graphics g = Graphics.FromImage(dstImage)) { RectangleF r = new RectangleF

Why is my line not drawing?

。_饼干妹妹 提交于 2019-12-17 21:24:04
问题 So I have defined a mouseEventlistener and mousemotionListener to define points as so. protected Point elementPosition = null; public Point endPoint = null; public Axis tempAxis; public Graphics g; class MouseButtonHandler extends MouseAdapter { public void mousePressed(MouseEvent e) { if(e.getModifiers()==InputEvent.BUTTON1_MASK) { elementPosition =new Point(e.getX(), e.getY()) ; if(addType==YLABEL) { YDialog ydia = new YDialog(anApp); ydia.setVisible(true); value =(double) ydia.getValue();

does change the field of view equivalent to multiply by scale matrix?

此生再无相见时 提交于 2019-12-17 21:20:19
问题 Using perspective view, does change the field of view equal to multiplying by scale matrix? Usally I think it is much natural to change the field of view. 回答1: No because in Perspective Projection scale is different for different distances The more distant object is the less scale it has that is why inside perspective matrix are goniometric functions. Btw. OpenGL gluPerspective has very inaccurate cotan causing problems when you try to overlap more perspective views together and also distorts

Java basic 2d game animation stutter

烂漫一生 提交于 2019-12-17 21:15:00
问题 So, I have been working on a 2d rpg for some time now and I can't seem to fix this one problem. The graphics seem to "jump" or stutter every few seconds for an unknown reason. This is getting quite annoying because I don't know what is causing it. Here is a very basic program I wrote that just has a red square that moves from one side of the screen to the other side. Even in this very basic program the square still stutters every few updates and I really can't figure it out for the life of me

Thread.sleep() stopping my paint?

拟墨画扇 提交于 2019-12-17 21:01:45
问题 I'm making a program that is trying to animate a card moving across the screen as if you actually drew it from a desk. Here is the code for the animating: public void move(int x, int y) { int curX = this.x; //the entire class extends rectangle int curY = this.y; // animate the movement to place for (int i = curX; i > x; i--) { this.x = i; } this.x = x; this.y = y; } this rectangle object is inside of a panel inside of a jframe. for repainting the panel, i have this: public void run() { while

Rendering to a single Bitmap object from multiple threads

社会主义新天地 提交于 2019-12-17 20:47:58
问题 What im doing is rendering a number of bitmaps to a single bitmap. There could be hundreds of images and the bitmap being rendered to could be over 1000x1000 pixels. Im hoping to speed up this process by using multiple threads but since the Bitmap object is not thread-safe it cant be rendered to directly concurrently. What im thinking is to split the large bitmap into sections per cpu, render them separately then join them back together at the end. I haven't done this yet incase you guys

How can one mix 2 or more color palettes to show a combined color value

删除回忆录丶 提交于 2019-12-17 20:47:08
问题 I'm trying to create a plot where color represents the combination of several values. In the example below, I am applying increasing values for red associated with the x-coordinate and increasing values for blue in associated with the y-coordinate. #required function 'val2col' from: http://www.menugget.blogspot.de/2011/09/converting-values-to-color-levels.html val2col<-function(z, zlim, col = heat.colors(12), breaks){ if(!missing(breaks)){ if(length(breaks) != (length(col)+1)){stop("must have

Android:Crash: Binary XML file line : Error inflating class (using SurfaceView)

萝らか妹 提交于 2019-12-17 20:44:53
问题 I'm having android surfaceView and in that I'm trying to add buttons to this. In the surfaceView canvas I draw something. And I have a thread class to keep drawing. package com.androidsurfaceview; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class androidsurfaceview extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate