draw

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

北慕城南 提交于 2019-11-27 00:35:37
问题 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

Delphi: draw own progress bar in List View

可紊 提交于 2019-11-27 00:15:37
问题 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);

Draw / Paint Outside Form

≡放荡痞女 提交于 2019-11-26 23:30:12
问题 Can we paint images and draw text... outside a form.. i mean literally outside... i know its stupid question to ask but CAN we... 回答1: 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")]

Change color of a single pixel - Golang image

无人久伴 提交于 2019-11-26 23:15:01
问题 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

Draw a rectangle in Golang?

大憨熊 提交于 2019-11-26 22:48:05
问题 I want to draw a mailing label with some rectangles, barcodes, and then finally generate a PNG/PDF file. Is there is a better way to draw a shape in Go other than to do it with primitives - pixel by pixel? 回答1: The standard Go library does not provide primitive drawing or painting capabilities. What it provides is models for colors (image/color package) and an Image interface with several implementations (image package). The blog post The Go Image package is a good introduction to this. It

Drawing rectangles on a JPanel

混江龙づ霸主 提交于 2019-11-26 22:26:48
问题 I have a JScrollPane and on top of it I have a JPanel named 'panel1'. I want some rectangles to be drawn on this JPanel. I have a class named DrawRectPanel which extends JPanel and does all the drawing stuff. The problem is that, I tried to draw the rectangles on panel1 by writing the following code : panel1.add(new DrawRectPanel()); but nothing appeared on panel1 then I tried, just as a test to the class DrawRectPanel : JFrame frame = new JFrame(); frame.setSize(1000, 500); Container

Write text on image in WP7

断了今生、忘了曾经 提交于 2019-11-26 21:57:45
问题 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

Draw on webcam using OpenCV

时光怂恿深爱的人放手 提交于 2019-11-26 21:50:09
问题 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(;;) {

Drawing between 2 images in 1 JPanel

自闭症网瘾萝莉.ら 提交于 2019-11-26 21:43: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

Null Pointer Exception on getGraphics()

淺唱寂寞╮ 提交于 2019-11-26 21:29:19
问题 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