I was able to crop white space from images using Bitmap. However, it is not supported in platforms other than Windows (https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only).
I'm using LibTiff from BitMiracle. How can I trim the surrounding white space from images using LibTiff?
Related
I have a Bitmap object that i want to print using Casio IT 9000 hand terminal (The reason we are using Compact Framework)
I can print the bitmap but for some reason it scales up at different devices. I have found a 'Vertical Resolution' setting at some test program which fixes this but i couldn't find how to use this value.
Internet tells me to use
Bitmap.SetResolution
function but SetResolution does not exists at Compact Framework 3.5.
Another workaround i have found is resizing the Bitmap but our original Bitmap creates a 4 MB object in memory. We are at the limit of memory usage so i can not allocate another Bitmap object without getting 'Out Of Memory Exception' device consistently throws.
So my current options i can think of are,
1 set the bitmap resolution somehow or
2 resize the bitmap without allocation another.
Is there any other way to do this, or how can i use the Vertical Resolution setting
The question is, how you print the Bitmap. There are no real printer drivers with Windows CE 5.x or Windows Mobile 6.x devices. So you need to either print directly to the printer port using the printer's native printer language or you use a kind of printer driver and library like PrinterCE. The information on how you print is missing here.
To scale a bitmap using a stream you can use openNetCF's libraries (ImageHelper class, see Problems using ImageHelper to resize images on OpenNetCF with HTC T3333 for an example).
As there are no real drivers, the scaling most be done by the application, except for printer languages that can scale themself (ie PostScript). In mobile world and with mobile printers, the printed bitmap size mostly depends on the printers resolution. So, if a bitmap is 250x250 pixels and is 'printed' to a printer (using native printer language, for example ESC/P) with 100dpi print resolution, the bitmap will be printed at 2x2 inch. If the printer has a native resolution of 200dpi, then the printed bitmap will be ~1x1 inch. You more or less set every print dot with the bitmap one by one. Such printers do not care about a bitmap resolution value as available with some bitmap formats like TIFF or JPG. These resolution values say, for example, the bitmap has a resolution of 150dpi. If printed with that resolution, the bitmap will come out with in the 'original' size. If the bitmap has 300x300 pixels at 150dpi, it's original size is ~2x2 inch. But if that is printed on a dumb 300dpi printer (no scaling support) natively, it will be printed at 1x1 inch.
The way XNA 4.0 render fonts on the screen is a step back from XNA 3.1, to say the least. Thankfully, using the Nuclex Framework has solved this problem. However, this is for spritefont files.
Is there a way Nuclex can support spritefont textures(Nubik's, etc...) as well? If not,
how do you take "not-so-common" font, convert it to a spritefont, and make sure it's displayed on another computer(which probably won't have that font installed)?
Spritefonts are compiled. You get a spritefont.xnb file when you build your content, and this file contains all of your characters (the ones you defined in the .spritefont file). Since the game uses the characters that are in these files - which get deployed with your game - there is no need for the target computer to have any fonts.
Also, there is no need for Nuclex to support spritefont textures - you can use these textures in your content as they are because they will remain unchanged. Nuclex fonts only use a different way of drawing characters than the default XNA Spritefont processor does. The spritefont texture characters are already drawn.
I want to record a video from my KINECT for the color and depth frames, one video for color frames and another for depth frames. I wanna do this in C# WPF Application..
any ideas about how to do this ?
Thanks a lot,
What are you trying to achieve? Do you need to store it raw/lossless or are you fine using a usual video codec? The rgb stream is a usual video sequence that could be encoded just well with a codec. However, the depth stream is storing 11 bits of depth information per pixel. If you dont mind the loss in information, you could reduce this to a 8 bit greyscale image stream. That all depends on what you want to do with the recording afterwards.
You should use the AForge.NET Library. It is able to use Kinect for both color and depth. Check out this example (bottom of page). The Kinect namespace is here. It includes both a KinectVideoCamera (color) and KinectDepthCamera.
AForge is easily integrated with WPF. If you need examples on using AForge with WPF, here is one, or just search the web.
Then of course, there is always the option of using Emgu cv. Here is one example of it with kinect.
I have a WPF application that includes buttons with PNG images. The actual images get scaled by grid control inside the button to about 32 pixels or so (depending on button size). At the same time my original artwork created in Photoshop is 250x250 pixels in size.
Currently I create artwork in Photoshop, add it to my WPF project as a resource, and have WPF automatically scale it to the button size.
Here's my question - if my original image is 250x250 pixels, and WPF squeezes it into a button so that it is only 32x32 pixels, does my output file contain the 250x250 image, or the 32x32 image?
I'm asking because if the app performance is going to be negatively affected by the original image size, I'd rather just scale it in Photoshop myself.
Yes, it will include the full file, because it can't recognize that it might not be shown larger at runtime. You can check this by decompiling your program using ILSpy.
I have a front-end program for PND's running Windows CE (both 5.0 and 6.0) It user a high quantity of images (currently in png format) as buttons or for decoration purposes. The images are loaded from the SD Card via the new Bitmap(path);
I'm currently using v3.5 of the framework.
Upon loading, OS + my application have consumed 75 to 80% of the device's memory.
Wich good ways are there to optimize all that files?
The only ways that come to my mind to optimise these picture would be to resize them to the real size they are needed (like most icons will be used in a 16x16 size) and if you store also as bitmap no your card you can also set the used color palette to a size that matches the exact needs of the given picture (e.g. a picture of 16x16 has 256 pixels. So you need a maximum palette of 256 colors, but maybe also a self-defined 16 color palette is enough, cause in your picture are only 16 different colors.)
As a second approach you could also check if you maybe have the same picture multiple times loaded. In this case you should load it only once and use it multiple times.
A last one, that came to my mind belongs to background pictures. If you have a solid background you don't need a fully sized image of it. Just take a 1x1 bitmap and stretch it to the needed size. The same counts for gradient backgrounds, but in this case you have a 1x2 bitmap which will be stretched. And last but not least if you have a regular pattern, just take the smallest unique brick out of it and use some tile mechanism.
If you create the OS, is it possible to store the images as part of the OS?
In case it is possible, and the image is loaded fully to RAM, you can load the images only on a need to display basis and unload them when not needed. This will eliminate some loading time as well since accessing RAM is faster than accessing the SD card.
Another trick in with the same concept would be to copy all the images to a RAM based FS and load them only on a need basis - the down side is that this needs to be done after every reboot.