drawing

How to display raw data as an image (Visual Studio c#)

我的梦境 提交于 2020-01-01 08:04:12
问题 I will be receiving some raw data that will be stored in a byte array, where each 2 bytes is a pixel value (16 bits/px). To start with, the array will contain 100x100*2 bytes (enough for a 100x100 pixel image). I would like to display this data in the Form window. Eventually, I would like to refresh the image with the new data to make it look like a video stream. No strict frame rate is required. How can this be done? Any code examples in C#? EDIT: After some suggestions and reviews of tens

how to get Bitsperpixel from a bitmap

痴心易碎 提交于 2020-01-01 07:33:06
问题 I have a 3rd party component which requires me to give it the bitsperpixel from a bitmap. What's the best way to get "bits per pixel"? My starting point is the following blank method:- public int GetBitsPerPixelMethod( system.drawing.bitmap bitmap ) { //return BitsPerPixel; } 回答1: Use the Pixelformat property, this returns a Pixelformat enumeration which can have values like f.e. Format24bppRgb , which obviously is 24 bits per pixel, so you should be able to do something like this: switch

WPF Drawing arrow heads along a path

不羁的心 提交于 2020-01-01 06:03:29
问题 Just wondering how I might go about drawing arrow heads along a path. The path will change direction and go through several different points. The arrow heads are designed to show the user which direction along the path they need to travel. I've tried to use a brush but it didn't work as I need the arrow heads to orientate them selfs along the path... 回答1: See Path Animations Overview and MatrixAnimationUsingPath It can be used to move a control along a PathGeometry and if you set

Ellipse Drawing WPF Animation

感情迁移 提交于 2020-01-01 03:22:15
问题 I am developing a control that is a rectangle area and will draw an ellipse in the rectangle area when a trigger occurs. This control will be able to host other controls like, textbox's, buttons, etc. so the circle will be drawn around them when triggered. I want the circle being drawn as an animation like you were circling the inner controls with a pen. My question is whats the best way to accomplish this. I've been doing some research and I could use WPF animation or I could use GDI+ to

Sankey diagram in javascript

旧城冷巷雨未停 提交于 2019-12-31 10:42:36
问题 I want to draw a Sankey diagram using Javascript. Can anyone provide some direction regarding the algorithms or libraries that are available for this? 回答1: This is a basic Sankey diagram using raphaeljs function Sankey(x0, y0, height, losses) { var initialcolor = Raphael.getColor(); var start = x0 + 200; var level = y0 + height; var heightunit = height / 100; var remaining = 100 * heightunit; function drawloss(start, level, loss) { var thecolor = Raphael.getColor(); paper.path("M" + (start -

Sankey diagram in javascript

落爺英雄遲暮 提交于 2019-12-31 10:42:20
问题 I want to draw a Sankey diagram using Javascript. Can anyone provide some direction regarding the algorithms or libraries that are available for this? 回答1: This is a basic Sankey diagram using raphaeljs function Sankey(x0, y0, height, losses) { var initialcolor = Raphael.getColor(); var start = x0 + 200; var level = y0 + height; var heightunit = height / 100; var remaining = 100 * heightunit; function drawloss(start, level, loss) { var thecolor = Raphael.getColor(); paper.path("M" + (start -

Draw on QWidget

ぃ、小莉子 提交于 2019-12-31 05:35:30
问题 How can I draw on QWidget(element on my form)? I read many tutorials but none of them covers what I really have to do(draw some Rect on QWidget) . I made a class MyFigure which inherits from QWidget, and at even paint wrote some code to draw a rectangle. Then, in my Form Create I create MyFigure object, and just show it. IT DOESN"T WORK!!! 回答1: QGraphicsView and QGraphicsScene are good for painting, but if you want to draw on QWidget you need to reimplement paintEvent: #include <QWidget>

WPF text rendering inconsistencies

旧城冷巷雨未停 提交于 2019-12-31 04:26:09
问题 WPF 4.0 notoriously fixed the blurry text issue. Setting TextOptions.TextFormattingMode="Display" uses pixel hints to line up characters, which works really well to improve clarity. However, it does not work while the program is running as a Windows service in session 0; the text goes back to "Ideal" rendering, which at small sizes is completely unreadable. Below is a comparison of the two renderings. Not running as a service: Running as a service: Rendering code: //rtb is a

Drawing Colors in a picturebox?

心不动则不痛 提交于 2019-12-31 04:15:11
问题 In C# i have a picturebox. i would like to draw 4 colors. The default will be white, red, green, blue. How do i draw these 4 colors stritched in this picbox? or should i have 4 picbox? in that case how do i set the rgb color? 回答1: You need to specify what it is you would specifically like to draw. You can't draw a red - that makes no sense. You can, however, draw a red rectangle at location (0,0) which is 100 pixels tall and 100 wide. I will answer what I can, however. If you want to set the

WPF, C#: Draw a line onto existing bitmap in image control

时光毁灭记忆、已成空白 提交于 2019-12-30 23:33:49
问题 I have a bitmap image in an image control I need to draw a red line on the bitmap each time I click with the mouse onto it, at the place where I clicked the mouse. I first thought of creating a Line object, but found out, that I cannot add the Line. I would need a canvas. But if I put my image in a canvas, my bitmap does not stretch over the whole canvas (I found out, that the coordinates of the bitmap determine the place on the canvas, so my bitmap is wrongly displayed.) Then I tried using