draw

How to draw gridline on WPF Canvas?

本小妞迷上赌 提交于 2019-11-28 05:06:44
I need to build a function drawing gridline on the canvas in WPF: void DrawGridLine(double startX, double startY, double stepX, double stepY, double slop, double width, double height) { // How to implement draw gridline here? } How would I go about this? Jeff Mercado You don't really have to "draw" anything with WPF. If you want to draw lines, use the appropriate geometries to draw them. In your case it could be simple really. You're just drawing a grid so you could just create a DrawingBrush to draw a single grid square and tile it to fill in the rest. To draw your tile, you could think of it

How to add a simple text label to an image in Go?

别说谁变了你拦得住时间么 提交于 2019-11-28 04:42:18
Given image.RGBA , coordinates, and a line of text, how do I add a simple label with any plain fixed font? E.g. Face7x13 from font/basicfont . package main import ( "image" "image/color" "image/png" "os" ) func main() { img := image.NewRGBA(image.Rect(0, 0, 320, 240)) x, y := 100, 100 addLabel(img, x, y, "Test123") png.Encode(os.Stdout, img) } func addLabel(img *image.RGBA, x, y int, label string) { col := color.Black // now what? } Alignment doesn't really matter, but best if I could write the label above a line which starts at the coordinates. And I would like to avoid external loadable

Delphi: draw own progress bar in List View

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 04:01:39
I have a list view and draw it with OwnerDraw . How to draw a simple and smooth progress bar with rounded angles and a line on the top as on a picture below? I need your help to apply a code below to my needs (my skills don't make it possible to edit). // TUbuntuProgress // Version 1.2 unit UbuntuProgress; interface uses Windows, SysUtils, Classes, Controls, Graphics, Math, ExtCtrls; type TUbuntuProgressColorSets = (csOriginal, csBlue, csRed); TUbuntuProgressMode = (pmNormal, pmMarquee); TMarqueeMode = (mmToLeft, mmToRight); TMarqueeSpeed = (msSlow, msMedium, msFast); TUbuntuProgress = class

Animating a Rectangle in Java

不羁的心 提交于 2019-11-28 02:19:15
I've been trying to get this rectangle to move that I've created using a for loop. All that's happening with this code is that there is an original rectangle and then a new one next to that rectangle. No animation happens, only those two rectangles show on the window. What are some methods to get this rectangle to animate? import java.awt.*; import javax.swing.*; public class Gunman extends JComponent { /** * */ private static final long serialVersionUID = 1L; public int x = 10; public int y = 10; public int width = 8; public int height = 10; public void paint(Graphics g) { g.setColor(Color

Write text on image in WP7

泄露秘密 提交于 2019-11-28 01:34:40
I am new to WP7 development and I would like to know how can I write text to image? First is it possible to do so? As in GDI we can write text to image as shown below: Dim pth As New GraphicsPath() pth.AddString(txtSample.Text, New FontFamily(DropFont.SelectedValue), 0, Integer.Parse(DropFontSize.SelectedValue), New Point(left, top), StringFormat.GenericTypographic) But in WP7 as I came to know that GDI is not supported.So how Can I do this? Edit: I need to select an image from the pictures hub or take a picture using camera and display it in an image control and write some text and save back

Draw / Paint Outside Form

依然范特西╮ 提交于 2019-11-28 01:15:48
Can we paint images and draw text... outside a form.. i mean literally outside... i know its stupid question to ask but CAN we... You can "cheat" by creating a form, and setting its TransparentColor property to its background color, then draw on it. However, this prohibits you from drawing the transparent color because it won't show. Or you could actually draw directly to the desktop. [DllImport("User32.dll")] public static extern IntPtr GetDC(IntPtr hwnd); [DllImport("User32.dll")] public static extern void ReleaseDC(IntPtr dc); IntPtr desktopPtr = GetDC(IntPtr.Zero); Graphics g = Graphics

Draw on webcam using OpenCV

北城余情 提交于 2019-11-28 01:09:46
I want to draw/paint on a webcam screen using OpenCV. Since I'm reading from a cam, the frames are constantly changing, so I'm trying to figure out a way to keep or save the drawing on the current frame and use it for the next frame. The code below allows you to draw on the screen but when it gets the next frame, the drawing is gone and it starts over. Could someone please help me ... Thanks. CvCapture *input; input = cvCaptureFromCAM( 0 ); cvSetMouseCallback("Demo",&on_mouse, 0); for(;;) { frame = cvQueryFrame(input); if(!image) { image = cvCreateImage( cvSize(frame->width, frame->height),

Drawing between 2 images in 1 JPanel

旧巷老猫 提交于 2019-11-28 00:28:00
I want to draw the lines between 2 JScrollPanes (first scroll pane on the left side, second on the right). These JScrollPanes contain images. I want to draw lines between these 2 images (use some layers, use some trick etc.). I tried do it different ways, but i failed. Is it possible? (if not, i will have to make 2 images in one JScrollPane and it won't be nice). EDIT I want to draw between 2 images - throught components - get some points from images and draw lines between them. I apologize for poorly formulated question. In order to accomplish this, I believe you'll need to make use of the

Null Pointer Exception on getGraphics()

时间秒杀一切 提交于 2019-11-28 00:26:56
my application looks like that, i am getting a null pointer exception at the draw() method, to be exact at g.drawImage(img, 0, 0, null) package com.ochs.game; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.swing.JFrame; import javax.swing.JPanel; public class Game extends JPanel implements Runnable{ private static final long serialVersionUID = 8229934361462702491L; public static final int WIDTH = 320; public static final int HEIGHT = 240; public static final int SCALE = 2; public boolean isRunning; private

Change color of a single pixel - Golang image

时光毁灭记忆、已成空白 提交于 2019-11-27 23:49:31
I want to open jpeg image file, encode it, change some pixel colors, and then save it back as it was. I'd like to do something like this imgfile, err := os.Open("unchanged.jpeg") defer imgfile.Close() if err != nil { fmt.Println(err.Error()) } img,err := jpeg.Decode(imgfile) if err != nil { fmt.Println(err.Error()) } img.Set(0, 0, color.RGBA{85, 165, 34, 1}) img.Set(1,0,....) outFile, _ := os.Create("changed.jpeg") defer outFile.Close() jpeg.Encode(outFile, img, nil) I just can't come up with a working solution, since default image type that I get after encoding image-file doesn't have Set