G
Guest
I've been tasked with writing a control for displaying previews from scan software we use. These are scans of plan drawings and are roughly 11000x8000, 1bpp CCITT compressed TIF graphics. I can used Image/Bitmap.FromFile to load them correctly, for display purposes I am creating a scaled render of the original image (so that paints don't have to perform scaling/sampling on every draw) which gets costly enough that we don't want to do it
Problem; I modified the code this morning to use the PixelFormat of the source image in creating this scaled image, now I need to draw the original image to this new image. But Graphics.FromImage() throws an Exception for our TIF images because the target image is an indexed image, and .NET doesn't seem to support this
I found one other post on the newsgroups related to this problem, and Microsoft's solution was to draw to a 24 or 32bpp image and then (for the original author's purposes) save to an indexed format (presumably GIF being that the post dealt with an 8bpp graphic)
That would work great (or well enough) for the original author's problem, but let's do some math
11000*8000=88,000,000 elements/pixel
Not knowing how the Image class was implemented for holding 1bpp graphics, I assume this requires
11,000,000 Bytes, ~10742.2 KB or ~10.4 M
This we could easily accomodate (memory requirements would be low for this image)
According to the post I originally found, the only obvious solution is to create a target graphic that is NOT indexed. Going back to the math this would require
88,000,000*4 Bytes = 352,000,000 B, ~343750 KB or ~ 335.7 M
Obviously we can't do this. It's almost obvious we need a graphics object that can work with an indexed image
My opening pointed out I am drawing to a scaled surface, so my target isn't really 335MB, it's around 30MB (roughly 8% of the physical 'pixel' size of the document). I must display these, but even this allocation is unsatisfactory, especially since my control will allow zooming in to the original document size of 100%, making the scaled image the same size as the source image
Does anyone have any suggestions? Maybe there is a way to scale the image without creating the new image object and drawing it myself? On the same note, can Microsoft drop the $ into the developer time it would take to make a graphics object that could work with indexed/paletted surfaces? This seems like something a fair percentage of developers might need, and if available, would obviously use, so why wouldn't it be done already (except to save time, or meet some design goal/model I may not be aware of)
Thanks in advance for any possible solutions, I'll poke around and look for some solutions and post what I find, we were really hoping to nix the sampling/scaling on every draw (panning code) since it was causing notable lag in the application (being that the original document has a massive resolution on it, even a 2ghz machine with 1gb of RAM takes effort)
- Shau
Problem; I modified the code this morning to use the PixelFormat of the source image in creating this scaled image, now I need to draw the original image to this new image. But Graphics.FromImage() throws an Exception for our TIF images because the target image is an indexed image, and .NET doesn't seem to support this
I found one other post on the newsgroups related to this problem, and Microsoft's solution was to draw to a 24 or 32bpp image and then (for the original author's purposes) save to an indexed format (presumably GIF being that the post dealt with an 8bpp graphic)
That would work great (or well enough) for the original author's problem, but let's do some math
11000*8000=88,000,000 elements/pixel
Not knowing how the Image class was implemented for holding 1bpp graphics, I assume this requires
11,000,000 Bytes, ~10742.2 KB or ~10.4 M
This we could easily accomodate (memory requirements would be low for this image)
According to the post I originally found, the only obvious solution is to create a target graphic that is NOT indexed. Going back to the math this would require
88,000,000*4 Bytes = 352,000,000 B, ~343750 KB or ~ 335.7 M
Obviously we can't do this. It's almost obvious we need a graphics object that can work with an indexed image
My opening pointed out I am drawing to a scaled surface, so my target isn't really 335MB, it's around 30MB (roughly 8% of the physical 'pixel' size of the document). I must display these, but even this allocation is unsatisfactory, especially since my control will allow zooming in to the original document size of 100%, making the scaled image the same size as the source image
Does anyone have any suggestions? Maybe there is a way to scale the image without creating the new image object and drawing it myself? On the same note, can Microsoft drop the $ into the developer time it would take to make a graphics object that could work with indexed/paletted surfaces? This seems like something a fair percentage of developers might need, and if available, would obviously use, so why wouldn't it be done already (except to save time, or meet some design goal/model I may not be aware of)
Thanks in advance for any possible solutions, I'll poke around and look for some solutions and post what I find, we were really hoping to nix the sampling/scaling on every draw (panning code) since it was causing notable lag in the application (being that the original document has a massive resolution on it, even a 2ghz machine with 1gb of RAM takes effort)
- Shau