473,473 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with large tiff files

I have large 1bpp tiff scans of arch. drawings that are typically 12032x16890
pixels (filesize is about a 1 meg +/-)

While I can readily view smaller (dimension) files, when I try to do
anything after loading

I've looked at most of the samples on the web in using GDI+... they all fall
over dead with these large files.

Any help is appreciated.


Jan 14 '08 #1
3 2930
On Sun, 13 Jan 2008 21:35:00 -0800, tkiehl
<tk****@discussions.microsoft.comwrote:
I have large 1bpp tiff scans of arch. drawings that are typically
12032x16890
pixels (filesize is about a 1 meg +/-)

While I can readily view smaller (dimension) files, when I try to do
anything after loading
Did you mean to complete that thought?
I've looked at most of the samples on the web in using GDI+... they all
fall
over dead with these large files.
It sounds as though even though the files are monochrome, when .NET tries
to load them it's trying to make a full-color image. And of course
12Kx17K at 24bpp is pretty huge. I'm not aware of any way to control the
internal format of an Image instance initialized from a file. You may
have to handle the loading yourself, by creating an appropriate 1 bpp
monochrome Bitmap instance, using LockBits to get the buffer, and read the
file data in explicitly, copying to the image's buffer.

Pete
Jan 14 '08 #2
Pete,

In my current (working) version of the app, I'm using straight GDI and a
third party library to initally read in the file, then I move/scale it over
dibsections and all is good.

I'd like to use the gdi+ and get rid of the 3rd party library.

Problem is, I can't get at the bits because (it appears to be as you say)
the gdi+ bitmap has already "done something to them". If I could get to the
bits, I'd be a happy camper, but I think I need to first get the handle to
the GDI bitmap with the GDI+ call Bitmap.GetHBITMAP which fails on the big
files (I could be wrong here).

I have a sample that uses the GDI+ Image, but each time it wants to draw
onto the graphics, it takes way too long since it appears to have to decode
+all+ the bits each time it draws. With my straight GDI version, once the
file is loaded and handed off to my dibsections it is fast with BitBlt and
StretchBlt.

TK

"Peter Duniho" wrote:
On Sun, 13 Jan 2008 21:35:00 -0800, tkiehl
<tk****@discussions.microsoft.comwrote:
I have large 1bpp tiff scans of arch. drawings that are typically
12032x16890
pixels (filesize is about a 1 meg +/-)

While I can readily view smaller (dimension) files, when I try to do
anything after loading

Did you mean to complete that thought?
I've looked at most of the samples on the web in using GDI+... they all
fall
over dead with these large files.

It sounds as though even though the files are monochrome, when .NET tries
to load them it's trying to make a full-color image. And of course
12Kx17K at 24bpp is pretty huge. I'm not aware of any way to control the
internal format of an Image instance initialized from a file. You may
have to handle the loading yourself, by creating an appropriate 1 bpp
monochrome Bitmap instance, using LockBits to get the buffer, and read the
file data in explicitly, copying to the image's buffer.

Pete
Jan 14 '08 #3
On Mon, 14 Jan 2008 00:14:00 -0800, tkiehl
<tk****@discussions.microsoft.comwrote:
In my current (working) version of the app, I'm using straight GDI and a
third party library to initally read in the file, then I move/scale it
over
dibsections and all is good.

I'd like to use the gdi+ and get rid of the 3rd party library.
But the 3rd party library is providing functionality that .NET doesn't
offer.
Problem is, I can't get at the bits because (it appears to be as you say)
the gdi+ bitmap has already "done something to them".
I didn't say the bitmap has already "done something to them". I said that
..NET is creating a full-color bitmap even though the file is monochrome.
If I could get to the
bits, I'd be a happy camper, but I think I need to first get the handle
to
the GDI bitmap with the GDI+ call Bitmap.GetHBITMAP which fails on the
big
files (I could be wrong here).
I think you are wrong. The monochrome bits are likely never in the
bitmap. .NET is likely reading the data straight from the file and
converting it immediately before putting it into the bitmap.

You will need to "get to the bits" by reading the file yourself. This
would essentially involve rewriting the functionality of your 3rd party
library. The TIFF file format is not complicated, and this would not be
difficult to do, but you might want to consider just using the 3rd party
library via p/invoke to deliver a monochrome HBITMAP that you can use to
initialize a .NET Bitmap instance.

You'll still have the dependency on the 3rd party library, but it will be
less effort than reading the file yourself.

This assumes that .NET will just wrap the HBITMAP rather than doing
something to convert it. I suspect that's the case, but if not then
you'll have to copy it into a Bitmap instance you've explicitly created to
be monochrome, again using p/invoke (get the DC from your new Bitmap and
use unmanaged GDI to draw the HBITMAP into the new Bitmap using the DC).

After all is said and done, you may find yourself wishing that you'd just
taken the time to learn the TIFF file format and import the bits directly
that way. :)
I have a sample that uses the GDI+ Image, but each time it wants to draw
onto the graphics, it takes way too long since it appears to have to
decode
+all+ the bits each time it draws. With my straight GDI version, once the
file is loaded and handed off to my dibsections it is fast with BitBlt
and
StretchBlt.
I doubt that the time is being spent "decoding" anything. By my
calculations, a 24bpp image the size you're talking about is roughly
600MB. It's likely that the time is simply all of that data being moved
back and forth to and from the swap file as it's needed. My guess is that
if you look at the disk activity while you're waiting for the bitmap to
draw, you'll notice significant activity.

Pete
Jan 14 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black...
1
by: ashish | last post by:
We are working on development of an IFilter component for Jpeg and tiff files.First ever test resulted in following error. We are using ifilttst.exe(which comes with windows 2003 resource kit.) to...
0
by: Will Arrowsmith | last post by:
Hi All, I am trying to create a .tiff file to fax using the windows fax service FAXCOMLib. I have created an array of images (bitmaps) and converted them to 1pbb format in order to allow...
3
by: Brad | last post by:
I'm working on a web app which will display LARGE tiff image files (e.g files 10-20+ mb). Files are hidden from users direct access. For other, smaller image files I have used FileStream to read...
1
by: Bala | last post by:
Hi I try to download the tiff files from my server. Its get downloaded but I cannot open with windows fax viewer. its says "No preview available" thanks bala here is the code which I am...
5
by: Sameer Gupta | last post by:
what are options for opening / handling tiff files in .Net framework ? which is the best library, namespace ? Please help Regards Sameer Gupta C# Designer & Developer Siemens UK
7
by: Ben | last post by:
Hi We are looking for a component that offers that offers the below for Tiff files: Image clean-up (deskew, despeckle) Printing capabilities from VB The ability to add text to image, e.g....
4
by: G E W hittle | last post by:
I have a directory of tiff files. I need to loop thru the files and count the number of pages in each file. Can someone point me to where this info is stored? GW
3
by: GiJeet | last post by:
Hello, we have an app that scans documents into TIFF format and we need to transfer them over the internet. If anyone knows of a SDK we can use that can compress TIFFs on the fly or even if it can...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.