Re: Problems drawing to a 1bpp (indexed) image.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ken Tucker [MVP] (vb2ae_at_bellsouth.net)
Date: 02/11/04


Date: Wed, 11 Feb 2004 01:36:44 -0500

Hi,

http://www.bobpowell.net/onebit.htm

Ken
-----------------
"Shaun Wilson" <mrshaunwilson@msn.com> wrote in message
news:3B875120-2F9C-4216-B10F-ACE6C890811F@microsoft.com...
> 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/pixels
>
> 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 MB
>
> 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 MB
>
> 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).
>
> - Shaun
>



Relevant Pages

  • Re: Tab Control
    ... I have figured out all the issues I raised about the menu control except for one: I do not want any text displayed with the menu items. ... The graphics I am using already include the necessary text, so unless there is a way to force the graphic to be behind the text, I need to display the items without it. ... "Nathan Sokalski" wrote in message ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • grid
    ... How can I control the numbers of the grids on a graphics? ... For example,I want to display 54*45 grids on one ...
    (comp.soft-sys.matlab)
  • Re: Graphics only visible in Full Screen Reading mode
    ... In both Draft and Print layout, ... How can I get the images to be visible, especially in draft mode? ... with a graphgic that will not display in draft view. ... In particular, Draft view doesn't show _any_ graphics, regardless ...
    (microsoft.public.word.newusers)
  • Re: Do I understand how Word deals with graphics?
    ... Word's default resolution for imported pictures is accessible on Tools ... >> size in pixels divided by Word's display resolution (which is sort of what ... a tendency to bloat when graphics are inserted. ... The more Pixels Per ...
    (microsoft.public.word.drawing.graphics)
  • Re: 44/16 or 96/24 ?
    ... but it's display size is wrong. ... The graphics look sharp and exactly as intended with IE6 when rendered ... I hire artists. ... Also, the pictures don't align ...
    (rec.audio.pro)