|
Another way to achieve this would be to use a Pixel shader and render in the completed image. While this[^] sample is in GL Shader, it is close enough that you could convert it into a DirectX shader.
|
|
|
|
|
Thanks Pete, I'll have a closer look at that!
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
I have a deck of Elder Futhark rune cards I hand drew myself some 25 years ago. On a large paper card on a drawing board. Back then Google was the belated Messiah, and online services such as rune drawing or font composition where very scarce. I did it all my little old self with a T-square, ruler, pencil, and other such steam-punk devices.
Having rediscovered the deck, I find the accuracy and attention to detail I put into each card remarkable; runes are drawn with black koki pens, on white card; the uniformity of line thickness close to perfect on most cards, and the points where lines meet have zero smudge or overlap, or whatever. These look, except for one or two, like they were printed.
I want to capture all these cards for part of a digital work, and because the cards have aged some 25 years, their edges are not perfect, although each card is still a very good 80mm x 100mm. I scanned sets of six cards, in a grid style, on A4 paper, and used a white brush to remove edge markings and other unwanted spots from the cards. I now have six perfect enough composite images of 5670mm x 4730mm (3 cards wide, 2 deep on each image). These 'final' images are all nearly perfect size to be divided into 6 smaller images, that make up the large ones, So, from 5680mm wide, we get three cards 1890mm wide, and from 4739mm wide I get 2 2365mm cards.
Now, how do I do this? Using a selection rectangle in Paint.NET is not for the feint of heart, and not much ambition for this task. I have done an incredibly lot of google research before asking here, but nearly all results advised I use the ImageMagic [^]convert command. I have tried several variants of the convert command to no avail, e.g. one gives a very small image out but still containing all six original images. Various other attempts here met with similarly strange results.
The basic command I\m trying to use is: convert 'LargeImage.jpg' -resize 120x120 thumbnail%03d.png
No object is so beautiful that, under certain conditions, it will not look ugly. - Oscar Wilde
modified 12-Jul-15 6:51am.
|
|
|
|
|
Sounds like you're looking for the crop command[^].
The width and height of the geometry argument give the size of the image that remains after cropping, and x and y in the offset (if present) gives the location of the top left corner of the cropped image with respect to the original image.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
So I would effectively, on card at a time, crop the whole drawing down to one-card size, save that card size drawing under a new name, then recalculate the offset for the next card, 24 times. No great effort if I get the process right once to start with. Thanks.
No object is so beautiful that, under certain conditions, it will not look ugly. - Oscar Wilde
|
|
|
|
|
You should be able to do it with a single -crop command:
You can add the @ to the geometry argument to equally divide the image into the number of tiles generated.
convert -crop 120x120 LargeImage.jpg tiles/tile%03d.jpg
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Here's a link to the ImageMagick documentation for the crop command.
From a quick look it will do exactly what you want.
Link added: http://www.imagemagick.org/Usage/crop/[^]
Cheers!
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
modified 13-Jul-15 9:08am.
|
|
|
|
|
What link?
No object is so beautiful that, under certain conditions, it will not look ugly. - Oscar Wilde
|
|
|
|
|
Sorry, I added the link!
Our office is out of coffee and I just came back from a three week vacation.
Now where's that switch to turn my brain back on?
Cheers!
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
I successfully create a custom cursor from a 32x32 32bpppArgb (GDI) Bitmap with the following code:
public static Cursor ToCursor(System.Drawing.Bitmap bmp, byte x, byte y)
{
var stream = new MemoryStream();
var hIcon = bmp.GetHicon();
try
{
System.Drawing.Icon.FromHandle(hIcon).Save(stream);
}
finally { NativeMethods.DestroyIcon(hIcon); }
stream.Seek(2, SeekOrigin.Begin);
stream.WriteByte(2);
stream.Seek(10, SeekOrigin.Begin);
stream.WriteByte(x);
stream.Seek(12, SeekOrigin.Begin);
stream.WriteByte(y);
stream.Seek(0, SeekOrigin.Begin);
return new Cursor(stream);
}
However the colors of my cursor are all wrong!
It looks like it is using a palette / a limited set of 16/32/256 colors?!
Is it possible to have 24bits/32bits colors cursor? (i.e. with millions of possible color value)
[EDIT] Solved!
I found a way to do it! With the following API in sequences:
GetHIcon() <br />
CreateIconIndirect() <br />
CursorInteropHelper<br />
There was just some nagging issue to avoid GDI Object leaks which I solved by creating a
class SafeIconHandle : SafeHandle
modified 4-Jun-15 20:19pm.
|
|
|
|
|
|
My cursor are created from code generated Bitmap, won't work!
Anyhow I found a way to do it! With the following API in sequences:
GetHIcon() <br />
CreateIconIndirect() <br />
CursorInteropHelper<br />
There was just some nagging issue to avoid GDI Object leaks which I solved by creating a
class SafeIconHandle : SafeHandle
|
|
|
|
|
You may want to look at Extended Cursors for .Net[^] as it has a whole bundle of features.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Thanks you!
Anyhow my problem was to make a cursor that like a zoomed version of the screen!! So it doesn't help!
But anyhow, all working by now!
|
|
|
|
|
I want to convert graphics such as rectangles, circles, etc. to truetype files. However, I can't write the geometry data for graphics to these truetype files.Is there have any code or tutorial to achieve this goal?
|
|
|
|
|
I am programming in C++. I have a lot of work that uses the GDI, GDI+ or the older canvas to display graphs and chart. I need to draw a 3D mesh surface using these tools. Is there any sample code using these draw tools?
|
|
|
|
|
Austin_Cpp wrote: Is there any sample code Quite probably, but you have to go and search for it.
|
|
|
|
|
I have searched quite a bit with no luck. Unfortunately GDI is not considered a good option for 3D programming and almost all the samples are in OpenGL or Direct3D. I really can't use OpenGL or Direct3D without major changes to my code. GDI+ almost feels obsolete with very little activity on code web sites.
|
|
|
|
|
hi, i am using c# and i have two color.
color p1, p2;
how do i compare if they are almost the same? as in like their color value with only very slight difference? should i compare the hue? with some threshold between the two.?
can anyone please advise.
|
|
|
|
|
I'm trying to import a terrain that I made in Blender by exporting it (from Blender) in .fbx format.
This model has only one modelmesh and Blender tells me in the top right hand corner that I have 16,384 verts which is correct since I divided my mesh into 128*128 equal parts.
I then imported my model into XNA using the Content pipeline and loaded it into a Model class.
I inserted a breakpoint on this line to "watch" the verticesIn.length property.
land.Meshes[0].MeshParts[0].VertexBuffer.GetData<VertexPositionNormalTexture>(verticesIn)
The verticesIn.length property was set to 54452, which is just over 3.3 times the number of vertices I'm meant to have as shown in Blender.
I'm using Blender v2.72 and XNA v4.0.
Any help will be greatly appreciated.
Kamran Kamal
|
|
|
|
|
I went through my model creation process again; saved and exported after each step and checked the number of vertices in XNA.
Everything appears fine until the deform modifier is applied in Blender.
As a work-around I decided to export my model after applying modifier. Importing the model into a new blender file, and then exporting the model. This worked!
Before doing this, I had tried exporting my model in .x format but this didn't make any difference.
I'm not sure if this problem exists with any modifier or just the deform modifer.
|
|
|
|
|
I'm doing quite a bit of graphics work that involves displaying material on a cartesian coordinate graph using GDI+ methods (DrawLine, DrawRectangle, etc) in the Paint routines of a PictureBox.
I'm always having to deal with scaling, rotation matrices and the other complications because the picturebox needs to have it's 'world' scaled rotated and translated before displaying normal Cartesian coords properly. Even with all this, it's always extra work to handle the fact that pens and some other graphics objects then draw their sizes transformed as well, and mouse events don't necessarily return points correctly.
Many years ago, I used TrueBasic and it had a drawing component that you could set up as simple as giving the width, height and everything transformed accordingly. I'm looking for a dotnet component that will give me a similiar object so I can stop having to customize the existing picturebox. Paid components are fine, but I have to be able to use GDI+ to draw in it or it must support something similiar. I do *not* want to use graphing/charting components that require the graphics objects/points to be stored in their own arrays or other unique systems. I want to do the drawing myself.
Any suggestions for a third party component?
|
|
|
|
|
please use System.Drawing namespace in your project.
where you find the Graphics class which will give you all option to Draw anything by using cartesian co-ordinate system.
for example..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace WaveformDemo
{
public partial class WaveDisplay : UserControl
{
[DefaultValue(10)]
int _XDivision; //Total X Division
[DefaultValue(10)]
int _YDivision;
[DefaultValue(10.0f)]//1 Volt per Division
float _voltsPerDivision;
[DefaultValue(10.0f)]//1 Sec per Division
float _timePerDivision;
[Browsable(true),DefaultValue(10)]
public int XDivisions
{
get
{
return _XDivision;
}
set
{
_XDivision = value;
}
}
[Browsable(true), DefaultValue(10)]
public int YDivisions
{
get
{
return _YDivision;
}
set
{
_YDivision = value;
}
}
[Browsable(true),DefaultValue(10.0f)]
public float VoltagePerDivision
{
get
{
return _voltsPerDivision;
}
set
{
_voltsPerDivision = value;
}
}
[Browsable(true), DefaultValue(10.0f)]
public float TimePerDivision
{
get
{
return _timePerDivision;
}
set
{
_timePerDivision = value;
}
}
public override Image BackgroundImage
{
get
{
return base.BackgroundImage;
}
set
{
base.BackgroundImage = value;
}
}
public override ImageLayout BackgroundImageLayout
{
get
{
return base.BackgroundImageLayout;
}
set
{
base.BackgroundImageLayout = value;
}
}
public WaveDisplay()
{
InitializeComponent();
_voltsPerDivision = 10.0f;
_timePerDivision = 10.0f;
_XDivision = 10;
_YDivision = 10;
_s = new Sample();
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
if (BackgroundImage != null)
{
g.DrawImage(BackgroundImage, ClientRectangle);
}
else
{
Brush b = null;
b = new SolidBrush(this.BackColor);
g.FillRectangle(b, this.ClientRectangle);
}
Pen pen = new Pen(ForeColor);
Rectangle r = new Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width, ClientRectangle.Height);
r.Inflate(new Size((int)(-ClientRectangle.Width * 0.1f),(int) (-ClientRectangle.Height * 0.1f)));
double xPixelPerDiv = (double)r.Width / (double)_XDivision;
double yPixelPerDiv = (double)r.Height /(double)_YDivision;
double TimePerUnit = _timePerDivision/_XDivision;
double VoltsPerUnit = _voltsPerDivision/_YDivision;
string s1 = null;
for (int i = 0; i <= _XDivision; i++)
{
g.DrawLine(pen, new Point((int)(r.Left + xPixelPerDiv * i), r.Top),
new Point((int)(r.Left + xPixelPerDiv * i), r.Bottom));
s1 = (_timePerDivision * i).ToString();
g.DrawString(s1, Font, new SolidBrush(ForeColor), new PointF((int)(r.Left + xPixelPerDiv * i), r.Bottom + 10));
}
for (int i = 0; i <= _YDivision; i++)
{
g.DrawLine(pen, new Point((int)(r.Left), (int)(r.Bottom - i * yPixelPerDiv)),
new Point((int)(r.Right), (int)(r.Bottom - i * yPixelPerDiv)));
s1 = (_voltsPerDivision * i).ToString();
g.DrawString(s1, Font, new SolidBrush(ForeColor), new PointF(r.Left - 15, (int)(r.Bottom - yPixelPerDiv * i)));
}
_s.Render(g,r,XDivisions*TimePerDivision);
//base.OnPaint(e);
}
Sample _s;
}
}
|
|
|
|
|
Thanks, I'm aware that the math can be done manually. I was hoping for a third-party component so I could focus my efforts elsewhere and not have to focus on writing code for the existing drawing components.
|
|
|
|
|
I've been searching for an answer, but I can't seem to find what I'm looking for.
Basically, I have a TTF font with some custom glyphs. I have successfully "painted" them on my OpenGL canvas (C# using Tao). My question is: is it possible to rotate the glyph (from 0-360 degrees)?
I need to be able to rotate the glyph depending on the heading data received - this way, the glyph is facing the correct direction.
If this is not possible, do you have any suggested alternatives? I've considered importing the glyph as an image and converting it to a bitmap - but I'm not sure if this will work either.
|
|
|
|
|