this might be a long shot but here it goes anyway:
Suppose I have a couple of images inside a folder. Is there a way I can create a blank image and place them (with X and Y coordinates) into it?
Just in case I have not been clear enough, what I would like to do is:
1) Generate a blank image
2) Insert into that blank image some other images
In few words, this should create a blank canvas where I want to insert a few images (pictures, for example) later.
(BTW, this is a Windows project in C#)
Check out the System.Drawing.Image and Graphics.DrawImage() classes in the .Net library. Between them, they should allow you to read, draw and save images.
Related
I am parsing a .sym extension font file to get the character shapes. Characters are to made using pixels and hence this font file contains information in such form that it shows which pixel is to be shown in black color and which is not be colored.
I have written logic to draw these pixels using Rectangles on a WPF canvas and everything works fine except for the fact that I am not getting a sharp image.
The purpose ultimately is to take the screenshot of this image of this canvas and paste wherever the user wants it to be pasted hence very clear image is required.
Also, when this image is exported in XPS and zoomed in, I get a very sharp image like below and hence I don't think there is any problem with the character making logic:
I don't understand why this mismatch in clarity is happening.
This is a WPF newbie's request for suggestions ( so there is no code here )
In my application, I present to the user a canvas onto which he can drag drop shapes, textboxes and images. Kind of like Visio. Now the user wants to save what he created to a file. How do I go about doing that, which classes do I use? And what data format choices do I have? What if I want to save it in XML format?
Most grateful for advice and pointers
You can convert it to a bitmap and then save the bitmap to file. To read it again just use bitmap BMP = bitmap.FromFile(file);
Update..
If you want to save all the changes that have been made you then need to create a file format probably something like:
Circle 1, 15 ,25, 100,250,10
Where the format is:
Shape size, positionx, positiony, rgb value
I want to know how to overlay one image over the over in Windows Phone. I did some search online, a lot of people suggest put two images into one grid and adjust the margin. However, my case is a little different. I'm making the background image of the secondary tile, I want to integrate the two images, store it locally and make the tile. So I can't put them into a grid. So what should I do in this case? Thanks!
You can create UserControl with any layout you wish (173x173px). Then, when you need to generate a tile, put this control to a page (probably out of the screen) and make and image from it with new WriteableBitmap(YourTile, null);. Than save these image to the /Shared/ShellContent/ and you are done
Probably there are better solutions for this task but this works fine too
I made this work using Ku6opr method using the following
WriteableBitmap bmp = new WriteableBitmap(173, 173);
bmp.Render(renderRoot, new TranslateTransform());
bmp.Invalidate();
where renderRoot is the usercontrol containing the Grid and the Image. I then save the bmp to the /Shared/ShellContent folder in Isolated storage.
I am trying to write a simple program that lets me overlay a dot on top of an image when the image is clicked. I can save the X and Y data back to my database but then I will want to be able to call that information back at a later date and overlay the dots again via code unlike the first time when the user had to click the image.
I got as far as capturing the X and Y of the click no problem but I am having trouble finding examples specifically for what I am trying to do. All of the examples online seem to be for saving the image with the added graphic but I do not need to do that as it will be the same image every time.
Once I can do this, I also need to work out a way that I can detect what area of the image has been clicked. The areas I need to mark out vary in shape and size so I need to try and work out a way to 'map' these areas and then cross reference with the co-ordinates of the users click (I assume that I may need to do some clever geometry stuff for that?)
If anyone has any suggestions of what subjects/classes/methods etc. to research for either of my queries, I would very grateful.
Thanks in advance
You can use the System.Drawing namespace to achieve this.
Create a control and override OnPaint and OnPaintBackground. Store your clicks in a List
In OnPaintBackground, draw the image using DrawImageUnscaled using the graphics object which is passed to you as a parameter.
In OnPaint, loop through your points array and call graphics.FillElipse or similar to draw a little dot.
Because this isnt a retained mode graphics system, you need to keep drawing these items so this may not suit a large number of dots. In that case, you can create an in memory bitmap and get a graphics drawing object using graphics.FromImage.
i will need to print an "x" according to the coordinates given to me from one of the tables in my database. im probably gonig to use c# to connect to mysql.
i will probably have a winform that is 8.5 x 11 inches (The size of a regular sheet of paper) and i will populate the entire thing with labels of "x" and they will be invisible.
each individual table record will have the coordinates of those labels which should NOT be invisible
the form for every record will show and will print. the printing will be on top of a paper that is actually a physical application itself.
the problem:
how to fill out a physical application using data from a mysql database. (dont tell me that i should be printing the entire app from scratch, the reason this is not possible is because the form is actually TRIPLE paper width (white, yellow, and pink copy), so i cannot print the entire app from scratch, i have to print on top of it.
the question: how do i print "x" at specified regions? is my solution the best way to go or is there a smarter approach?
in case you have no idea what i am talking about, here are some related questions:
ms-access: designing a report: printing text on specific x,y coordinates
Conditional formatting in Access
While labels would offer you the ability to make an X show up I don't feel that having a bunch of hidden labels is the best way.
Does the "application" represent some kind of form? Are you looking to "check-off" boxes using x's and then print this?
I may suggest using GDI+ (drawing) vs using labels.
Consider the following:
Locate the coordinates for your boxes. Then use the drawstring method within an overridden onPaint event-handler for your form or for the panel which may represent your form's canvas.
This article talks about GDI+ and how to draw text as graphics.
http://www.functionx.com/vb/gdi+/objects/fonts.htm