Alper Selvi
Alper Selvi

Reputation: 13

How can i set bitmap resolution in compact framework

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

Upvotes: 1

Views: 232

Answers (1)

josef
josef

Reputation: 5959

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.

Upvotes: 1

Related Questions