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.
Related
My final goal is to get screenshots of a cropped area on the screen as fast as possible.
I'm using the the desktop duplication api with sharpdx to retrieve the full screenshot from windows according to the official sample :
https://github.com/sharpdx/SharpDX-Samples/blob/master/Desktop/Direct3D11.1/ScreenCapture/Program.cs.
I'm currently cropping at CPU level with a pinned memory bitmap and Buffer.BlockCopy on the raw bytes which, IMO, cannot be considerably anymore faster.
Is it possible to apply a simple crop operation at GPU level?
I'm using the ImageResizer .net library. It works as expected, but one image messes around.
I've uploaded the image below. I've already tried some things like format=jpg&quality=100, only width=220, also different sizes, but it always adds this blurry border around the image.
The original image is a png.
This one is the original image:
This one is resized by the ImageResizer:
And this one is resized with photoshop:
EDIT:
If you're running into the same issue. Try to set up the SpeedOrQuality Plugin. I've set it to speed=3 and the image is sharp again.
Vector graphics require different resampling algorithms than photographs.
ImageResizer V4 includes higher quality image resampling options under the FastScaling plugin.
For graphics (non-photographic images), I suggest playing with &f.sharpen=0..100, &down.preserve=-5..5, and &down.filter=Robidoux. Make sure &fastscale=true and FastScaling is installed.
You can certainly find a good configuration for your rasterized vector art and set up a preset for it. FastScaling is capable of much better resampling than Photoshop - on par with Lightroom, in fact.
Enabling fastscaling alone helps substantially (?width=200&fastscale=true):
Adding sharpening gives a very clear result: (?width=220&fastscale=true&f.sharpen=100):
Visibly crisper than Photoshop:
Each time you save a jpeg, you loose quality (the image is reencoded).
I would recommend using the same quality as the original image was save against, it should give the best results.
Using a higher quality is not recommended as it will artificially try to improve quality, mistaking approximations done by previous encoding for details, resulting in things like the blurry border.
Aside that, usually, one should not use a quality over 95 for jpeg encoding.
i succesfully managed to add ability of displaying and printing svg to my app, to achieve that i've used https://github.com/vvvv/SVG. Library renders bitmap from provided SVG file, and thats ok as far as it comes to editing. Problem starts when it comes to printing. Files are printed with PrintDocument component to virtual PDF printer and when text sent to print is smooth, svg elements are bitmaps, and what i had in mind to benefit form that "high quality" look that svg provides. Is there any way to send SVG straight to printed page without transforming it to bitmap?
One possibility: when you start printing, re-render the SVG into a new bitmap used just for the print job, where the bitmap size takes into account the actual print resolution for the job. That is, if you are printing at 300 dpi and want the SVG to print in an area 2x2 inches square (for example), the bitmap would be a 600x600 bitmap instead of whatever you used for screen display.
Note that this means your PDF will contain the high-resolution bitmap, making it much larger. This addresses the quality issue, but at the expense of file size.
Without a platform API that will actually draw an SVG to the Graphics instance for the print job (which I'm not aware of), it would be harder to keep the SVG data in a vector format.
That said, I didn't look at the library you're using closely, but if it's using a Windows API to render into a bitmap, that means there's probably an HDC (native Win32) or Graphics (.NET) instance being drawn to. You can use a metafile for the HDC or Graphics object instead of a bitmap, and that will preserve the vector nature of the rendering, which in turn might be preserved when you render it to the PDF printer driver (at that point it will be all up to the PDF printer driver, which is out of your control).
I have an application that has uses the PrintDocument object for printing reports. Reports are rendered in EMF and everything is fine until you run the application as an RemoteApp.
As RemoteApp, the application cannot get the client monitor's DPI and will default to a 4:3 ratio. If the client's desktop resolution does not match this ratio, the report will be scaled incorrectly and thus, prints are also incorrect. For example, the fonts will overlap each other.
I know rending in PDF is fine, but it requires saving a temp. file first. However, I also require batch printing, so this may not be the best solution in terms of performance.
Does anyone know of anyway to get around this besides making sure the client desktop has the same 4:3 resolution ratio?
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.