 |
|
|
 |
|
 |
Sure. Take a look at the methods on Graphic. You can draw lines, curves, text, images, .. lots of fun stuff!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Any insight on making this support carriage returns inside the overlay text? If I place \r\n into the mix, the calculations are thrown off.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
If you are using the demo, just press [CTRL]-Enter to break to a new line. If you are using the code, use the C# version .. \r\n is just characters in VB. For VB (or C#), you can use Environment.NewLine.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
First of all thank for a great job.
Is it possible to move text anywhere in the image through the mouse.
If yes can you tell me how?
Thank you.
Rajesh.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks, Rajesh.
It would be possible to move the text with the mouse, but it would require a lot of coding. The demo app was only meant to show how the function operates, not as a front-end for creating graphics. If you want to try, start with the MouseDown and MouseMove events. On second thought, it might be easiest to use a draggable transparent label (or panel) control sitting on top of the graphic ...
However, for your purposes, you may want to just use a graphics program. There are many free ones available
HTH
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
I think that code is great. However, I'm looking for I way to write overlay text outside the program Window. For exemple, I'd want to tell that small program to write Hell World in a specific coordinate of my Internet Explorer window, which is opened besides of my program. I'm coding in C#. I guess The Code Project have already covered that subject but I can't find any specific information. Can someone help me with that?
Thanks in advance.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
I am just looking for this to do a dual screen Bible presentation program. May God bless you.
Is it easy to add tab (\t) and newline (\n) support?
Best regards, Paul.
Jesus Christ is LOVE! Please tell somebody.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Paul, The Overlay method will use newlines if they are in the text sent. Just change the textbox in the demo to be multiline to test. If, however, you want the text to only break at your newlines, you need to add a flag to the following line: strFormat.FormatFlags = StringFormatFlags.NoClip | StringFormatFlags.NoWrap; // add NoWrap to preserve layout.
You'll also need to widen the initial rectangle, or you can end up clipping (even with the NoClip flag).
Tabs, unfortunately, are not as easily supported. If the tabs are always at the beginning of a line (like paragraph indention), then you can just replace them with 3 or 4 spaces to simulate a tab.
What you're *supposed* to do is use the SetTabStops() method:
strFormat.SetTabStops(0F, new float[] {60F});
However, you may need to play with the values and maybe even base them off the calculated font size to get good results. In fact, until I added NoWrap, I couldn't get the tabs to show at all, and afterwards, the values I used didn't seem to have any effect. There's not a lot of info on SetTabStops().
HTH
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks for the support. I think the space for the tab will do.
Best regards, Paul.
Jesus Christ is LOVE! Please tell somebody.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
You can set TabStops easily. In my program, I needed to render Text like a Document. So, I set the GraphicsMode to Document in my graphics object and used this for the TabStops... My Tabs are about a 1/2 inch apart.
sFormat.SetTabStops(0.0f, new Single[]{(float)(300.0 * 0.55)});
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Great job on the example but..... well OK it was a great job regardless. Only thing is I really need to do non-destructive text annotations in an image. Anyone know how to do this?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I'm not sure what you mean by "non-destructive" ... in a sense, the function is non-destructive, because it uses a copy of the original to annotate. The image you pass is not changed; you get a new image back.
But I imagine what you are talking about is more like a "layered" image (the way PhotoShop works). You could have the original on the bottom and the text on a transparent layer above. There is one "standard" image format I'm aware of that supports layers -- TIFF, but it's not a widely used format.
However, if you're looking for something like a marquee with scrolling text and a background image, the best bet (other than finding one already made) would be to inherit from a control (like a Panel) and override OnPaint().
GW
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi there... I’ve a problem to add code on load images from hard disk. I’ve try many times to add that code, but it’s still don’t work. The text doesn't appear on image. So, can you please help me? thanks..
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Bariah, The demo code stores the original image in a form variable m_OrigImage so that when you change the parameters or text it will overlay onto a "fresh" (clean) image.
To use your own image, you just need to load it and set m_OrigImage to your image (for example, m_OrigImage = Image.FromFile(filename)). I'll update the demo so it can load an image, but it may be a couple of days before the update gets posted.
If using the function in another project, you would load your image and pass it to the Overlay( ) function, which returns the modified image.
GWSyZyGy
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi
I have add in some code to save the image as jpg file and open the jpg file in IE. I found that image display in IE quite dirty, noise?
Any solution to make it nicely? Thank Alot Cliven Yong
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Well, not knowing what your code looks like, I'd have to guess the quality parameter you used is too low. JPG is a lossy format, and the .NET jpg encoder is somewhat ... lacking.
If you want to preserve the information, I would suggest saving as either bmp or png. Then you can convert to jpg in something like PhotoShop (that will do a much better job).
Here's some code that will let you do that:
Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim bmp As Bitmap = New Bitmap(pbOverlay.Image) Dim dlg As New SaveFileDialog() dlg.AddExtension = True dlg.CheckPathExists = True dlg.CreatePrompt = False dlg.OverwritePrompt = True dlg.RestoreDirectory = False dlg.ValidateNames = True dlg.FileName = "Overlay" dlg.Filter = "Jpeg Image (*.jpg)|*.jpg|PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp" dlg.FilterIndex = 0 If dlg.ShowDialog(Me) = DialogResult.OK Then Select Case dlg.FilterIndex ' NOT zero-based! Case 1 '"jpg" ' get compression Dim iQual As Integer = -1 Dim sQual As String = "90" While (iQual < 0 Or iQual > 100) sQual = InputBox("Enter jpg quality (0-100)", "JPG Quality", sQual) Try iQual = Integer.Parse(sQual) Catch iQual = -1 End Try End While
Dim eps As EncoderParameters = New EncoderParameters(1) eps.Param(0) = New EncoderParameter(Encoder.Quality, iQual) Dim ici As ImageCodecInfo = GetEncoderInfo("image/jpeg") bmp.Save(dlg.FileName, ici, eps) Case 2 '"png" Dim ici As ImageCodecInfo = GetEncoderInfo("image/png") bmp.Save(dlg.FileName, ImageFormat.Png) Case 3 '"bmp" bmp.Save(dlg.FileName, ImageFormat.Bmp) Case Else MsgBox("Unrecognized selection!", MsgBoxStyle.Exclamation) End Select dlg.Dispose() End If End Sub
Private Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo Dim j As Integer Dim encoders As ImageCodecInfo() encoders = ImageCodecInfo.GetImageEncoders() For j = 0 To encoders.Length If encoders(j).MimeType = mimeType Then Return encoders(j) End If Next j Return Nothing End Function
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi.
I'm sure you already know this, but to get rid of the jagged edges you can use the following method.
Let g be the Graphic object.
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias
This heavily reduces or eliminates the jagged edges. (Obviously with a slight performance hit, but for this kind of drawing it's worth it.)
Great example overall.
Keep it up.
/ Thomas
Wit is educated insolence.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
Nice little article!
I've developed a VB.Net utility which uses Photoshop scripting to create a new set of JPG images from an existing set, allowing the user to resize, add saturation, define the output image quality and a bunch of other Photoshop stuff. It even uses PS7's own JPG optimisation to create *really* good images... I use this utilty to prepare compressed images and thumbnails for my website. (I'll post it on my site one of these days so everyone can get at it but it still has a bug or two!)
Anyway, the only other thing I've wanted to add is to allow the user to specify a copyright message or other text on the image. This would most likely be in one corner in a very small font. So far I've not had much luck doing this using PS7 scripting as it is difficult to do the positioning accurately for the same reasons you mention in your article. So, I'd like to see what you've got above extended so the text could be placed in any corner, not just in the center. But you've given me somewhere to start... thanks!
Mike.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Mike, Well, it only took 6 months, but I finally got around to it. The latest version lets you specify the position, as well as the relative scale (no longer hard-coded to 80%).
Enjoy,
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Good for you! A bit late for me thoigh - I solved my PS problem with positioning text about 4 months ago. I'll still download the source as future reference though.
Mike.
|
| Sign In·View Thread·PermaLink | 3.50/5 (2 votes) |
|
|
|
 |