Condensing text of label without resizing font - vb.net

I'm posting this question because I'm in front of some kind of wall there..
I need to be able to condense the text of a label to make it fit but without touching at the font size. Basically, just squeeze the text.
Here an image that should be clearer to understand :
Normal/Condensed Font
I've searched a bit but it's pretty uncommon actually.
I doubt it's possible without modifying the font itself but if anyone has an idea, that would be awesome.
N-B: I'm using VS2015.

Related

White Border on Photoshop Text

I am trying to match the "teletext holidays" in the image below (with the white bits connecting all the letters:
I have achieved the following by going to the layers section, right-clicking the text layer, and select “Blending Options.” Then marking the checkbox next to “Stroke.”
Any hints or tips to point me in the correct direction would be appreciated. I appreciate moving the letters within the font closer together will help so will work on that now.
Any help appreciated.
Update:
Made the letters appear closer together. However, using stroke is making the black letters "shrink" in size so think a different solution is required. Thoughts?
With regard to that final image and the black letters appearing smaller. When applying the stroke, tick to indicate that it should be outside and not center or inside
And with helping to ensure that the white parts do meet.... Hmm... Well. Difficult to do the horiztonal stroke without it also applying vertically.
I would agree with others that Illustrator would be better but in Photoshop I might try to duplicate the text, make it all white, put it on the layer behind your main text and manually create a horizontal white pattern.
^ I really hope somebody has a better idea for that last bit though.
Alan,
I would like to help you with this issue. First of all your reference design is designed in adobe illustrator not in photoshop because there is some limitation in photoshop for the stroke feature.
So I would like to suggest you design it in adobe illustrator and not waste your valuable time in photoshop for your desired output.
If you need more help regarding it feel free to contact me at niravmistrydata#gmail.com.
Thank you,
Nirav Mistry

What is the use of System.Drawing.Graphics.Clear(Color pColor) method?

Well, I'm resizing an image in VB.NET. I have predefined algorithm that converts the image into particular size.
I just found a bug in the algorithm which causes white linings on right side of the image. After debugging the code i found that,
Dim grReturn As Drawing.Graphics = Drawing.Graphics.FromImage(bmpReturn)
grReturn.Clear(Color.White)
causes the issue. I tried googling the issue and found just a single MSDN link which says it clears the entire drawing surface and fills it with the specified background color.
And i am not able to understand what it says!
I am able to remove white linings from my output image by commenting this Clear function. As i don't know what this function actually does, i can not remove it.
So if anyone could help me understanding the method? Will it cause any other issue if i remove this method?
Thanks!
Clear method simply draws the background of the graphics to the provided color code.
As per Varocarbas comment above question,
"The explanation you are posting sounds pretty descriptive: it sets
the background of the graphic (future image) to the given color. From
what you are saying, your problem is not provoked because this code
"draws lines", but because it makes the whole background white and the
size of bmpReturn does not occupy all this background (and thus the
white lines you see are not more than parts of the background). If you
don't want this effect, just don't use this line of code; and, in
general, you shouldn't use code whose exact functionality is not clear
to you"

Is there a way to take an image file and make its background transparent via VB .NET?

We have a system where people are being taken a face shot via a DSLR camera. We need the people's images with transparent background. What we're currently doing is taking the image and editing and cropping it in Photoshop, removing the background image with the Magic Eraser tool.
What I am looking for is a way to parse the image and automatically erase the semi-white background we have, along with the resizing and cropping. Is there some kind of library or code sample that does this without requiring manual intervention?
This is a real complex problem. Like the answer below suggested you'll need to do a fuzzy match on each pixel and set it to be transparent but you also need to detected other nearby pixels to make sure they are not close in color. A white tag on the shirt, white eyelids, hair, pale skin reflecting the flash. All are candidates to be removed by any greedy fuzzy logic.
Think about the Magic Wand tool in Photoshop. How good is it at detecting the edges of the person in the picture? Yeah, and that's the top standard of image editing software with thousands of engineering hours behind it.
This is not a feasible request for a Q&A format, and this is one of those things that humans just do better than machine. BUT, that doesn't mean it's not possible, and who knows, you might be the one to do it. Just don't do it in VB.NET please :)
Some pseudo-code to get an idea of what you need to do:
Bitmap faceShot = Bitmap.FromFile(filepath)
foreach pixel in faceShot
//the following line is where the magic happens, you can do any fuzzy match on the color that suits you
//figure out your color range and do a fuzzy match percentage wise
if (pixel between RGB(255,255,255) and RGB(250,235,215)) //white and antique white
pixel.setAlpha=0
endif
end foreach
You could start with this as a starting point for processing a single image,
http://www.java2s.com/Code/VB/2D/ProcessanImageinvertPixel.htm
Basically, if you have a constant background color (like the TV green-screen), it's just a matter of selecting pixels close to the color you are erasing and setting their Alpha level to 0 (transparent). Treating the RGB values like XYZ coordinates, you can do a 3d distance from your background color, and make everything within a certain threshold transparent.
As an improvement, you could also make everything within another threshold semi-transparent so the edges right around hair and stuff like that look softer and less harsh.
Alternatively, you could probably do the same exact thing with good results in Photoshop, as it should support batch processing.
Edit, thinking about it some more, you may want to use a green screen type background as well instead of an off-white one like you stated, as you may make people's eyes transparent. I would definitely try to batch it in Photoshop/Gimp/etc.

Objective-C: How to implement TextView orphan control

I'm working on an iPad app that does a simple display of text similar to iBooks.
I would like to display ONLY full paragraphs on each screen (ie, no orphan/widows on a page). Similar to iBooks, I want to allow the user to change the font and font size and continue to keep all lines in paragraphs together. The user will be able to page forward and backwards (just like iBooks).
I've been researching this and can't find a solution for this. I would think that someone has already done this code, but it looks like I'm going to have to figure out the point size of the font and calculate the size of the TextView and then count how many characters, etc etc etc.
Does anyone have a suggestion where I might start to do this?
Thanks a bunch!
Look at the NSString UIKit Addition it has methods for calculating how much space the rendering of string in a give font will take.

Using System.Drawing to make a selection tool, and cropping an image in vb.net

If i wanted to crop an image in VB.net, how would I go about doing it? I am trying to let the user drag out the box they want (system.drawing.rectangle), and it will automatically remove the edges surrounding the box.
My first problem is primarily the fact that I cannot make the system.drawing.rectangle visible. It is not displaying at all, I am setting its location and height programmatically, but nothing is showing up. I know there is probably something fairly obvious I am missing...but I cannot seem to find it.
My larger issue, however, lies with the cropping itself. I cannot find any crop methods, at all. Is there a hidden one I am missing? Or must I code it myself? How would I go about doing this? It ought to be able to output to a bitmap image object.
Thanks for the help, I am surprised this hasn't been asked on here before....
Regarding your first problem: a Rectangle isn't by itself visible. You have to draw it on your canvas using the Graphics object's DrawRectangle(...) method. For drawing a selection tool, you'll want to set your Pen object's DashCap and DashPattern properties.
To "crop" an image, you basically want to take the portion of a larger image delineated by a smaller Rectangle, and turn it into a new Bitmap. This can be done using one of the 30 overloads of the Graphics object's DrawImage(...) method. You can either keep the cropped portion in its original dimensions (resulting in a smaller Bitmap than your original), or you can "blow it up" to something like the original image's size. If you do the latter approach, it is usually a good idea to set your Graphics object's InterpolationMode property to HighQualityBicubic (I think that's the one, anyway), since the default InterpolationMode is pretty crappy.
There are a number of different ways of rendering images in .Net - it might help if you posted some of your code, along with an explanation of the exact problems you're running into.
Here is another answer with a link to a sample app (and source code in C#, sorry) that may help you get started.
There are a number of articles on these topics on CodeProject:
Pick your favorite flavor (though I encourage you to check out the C# projects - it shouldn't be too hard to convert).
VB
Image Cropping with Image Resizing Using vb.net
C#
Cropping Images
An Easy to Use Image Resizing and Cropping Control
Image Processing using C# (see the Cropping section - I was able to use this code in one of my projects)
WPF/C#
WPF Interactive Image Cropping Control
A Photoshop-like Cropping Adorner for WPF