CDC Issue

<wdhough@discussions.microsoft.com> wrote in message
news:069f1a60-2d1e-46dc-8474-f2de281812e1@discussions.microsoft.com
> I have an application that draws a diagram in the form of a bitmap
> and then displays this in a window.  There are limits placed in my
> code that do not allow 
> the CSize properties cx and cy to be set to more than 32000 in
> 'SetViewportExt' and 'SetWindowExt'.
 
You seem to labor under a mistaken impression that SetViewportExt and SetWindowExt somehow limit the size of the drawing. They don't. In fact, the absolute values you specify in these two functions are irrelevant - all that matters is a ratio of window extent to viewport extent, as this ratio is used to translate logical coordinates to physical pixels. If you set both extents to the same value, this ratio is 1 - the calls have no effect.
 
> CSize objects passed to the
> 'SetWindowExt' and 'SetViewportExt' methods had cy components that
> exceed 32000, in fact they were in the region of 69000.  However when
> i doubled the size of my diagram, which is draw as a bit map, it
> failed.
 
Are you running on Win9x (95, 98, Millennium), by any chance In these, GDI is implemented in 16 bit code (a legacy of old Win16 systems). As a result, it can only handle coordinates in the range [-32768, 32767]. It sounds like you are hitting this limit.
--
With best wishes,
    Igor Tandetnik


Answer this question

CDC Issue

  • Jing Sun

    To my knowledge we dont render anything larger than the clients screen area.  Its when we get to a really large document, like a couple of hundred pages long that this happens.  I assumed the problem was with CDC since that would be involved in the drawing/painting process, when we get to about 120 pages long the document has lines appearing at the top, only the top leftish area, and once you scroll down you can obviously no longer see them, however if you scroll up again there are still there, they have actually permanently been painted there.  It sounds and looks like a problem other developers would have come across, when loading very large documents, so i figured there might be some information about it out there   But we do only ever render what the viewer would be able to see, ie the area of the client window

    Will

  • John Ericson

    <wdhough@discussions.microsoft.com> wrote in message
    news:123f6aaf-369f-45e3-a061-700567232433@discussions.microsoft.com
    > Sorry just another thing to add, I noticed that we have the following
    > call that checks that appears to check that the area we are rendering
    > is never larger than the window size.  I have checked through this
    > code with a debugger and the 'if' statements never seem to be
    > satisfied, nothing wrong with that!.  However i checked out the
    > attributes of the psize object of type CSize.  its cx and cy
    > components, for this enormous document that i am testing through are
    > about 60000 and 1500 ish.  This is obviously not the size of the
    > window that i can see, so is there a problem here
     
    How should I know I didn't write this code. Ask the person that did. It's definitely not representing an on-screen visible rectangle - I'm hard pressed to imagine a device having 60000 pixels along one dimension.
    --
    With best wishes,
        Igor Tandetnik

  • Paul Ballard

    As long as all calculations and coordinate results are in a range less<32bit int value there should be no problem. Are you sure that in your calculation there is no overflow

  • Erik Edlund

    I have an application that draws a diagram in the form of a bitmap and then displays this in a window.  There are limits placed in my code that do not allow
    the CSize properties cx and cy to be set to more than 32000 in 'SetViewportExt' and 'SetWindowExt'.  This limits my the amount of my diagram that i can draw, and believe it or not someone has managed to make a diagram that exceeds that would exceed the cy component of this diagram.  I took these limits out in order to be able to display the whole diagram and it worked well, the CSize objects passed to the 'SetWindowExt' and 'SetViewportExt' methods had cy components that exceed 32000, in fact they were in the region of 69000.  However when i doubled the size of my diagram, which is draw as a bit map, it failed.  Let us be clear the parameter is was now setting the CSize object to that would be passed to the two previously mentioned methods, were 140000 (cy component) and 2000 (cx) component.  The failure was that i had lines running over the top of my diagram, i spoke to someone who was previously involved this project and they told me without those limits, i was "killing the DC", sadly he couldnt tell me, anymore, it seems that there is some sort of limit

    Can anyone help me with understanding this, or perhaps offer a solution

    Many thanks

    Will

  • WizDum

    <wdhough@discussions.microsoft.com> wrote in message
    news:13374d9c-a551-47c7-8e82-2c407b523525@discussions.microsoft.com
    > To my knowledge we dont render anything larger than the clients
    > screen area.
     
    Then why do you need those huge coordinates Do you have a monitor with 32000 x 32000 resolution
     
    > Its when we get to a really large document, like a
    > couple of hundred pages long that this happens.
     
    Again, I fail to see where the size of the document matters. An HDC represents the target device, not the source data. The target device does not grow larger as your document grows, now does it
    --
    With best wishes,
        Igor Tandetnik

  • Dania151638

    Hey thanks for the post, i'm actually running XP, the application will never run on win 9x, so thats not a problem.  I have been reading about the viewport and windowext stuff just now, your right cant really see how it would have any effect on the program positive or negative.  Do you have any idea whats wrong then   Is there a maximum storage limit for a CDC   The issue i have is applications like MS Word, or photoshop, or Adobe Reader are able to cope with documents that could be hundreds of pages long, and therefore its possible.  As i understand the CDC is something of a canvas which windows 'paints' too   I suspect i'm coming up against a limit in the size of that canvas, and wondered how those programs i just mentioned overcame that issue   Do they have multiple canvases and if so, how do they link them succesfully   I am quite suprised by how little i have found about this problem/issue on the web, which worries me as this would imply my problem is application specific!

    Any more thoughts would be a great help


  • genyded

    <wdhough@discussions.microsoft.com> wrote in message
    news:bab5bbe4-43ab-4f89-826b-ffd6edf9c450@discussions.microsoft.com
    > The issue i have is applications
    > like MS Word, or photoshop, or Adobe Reader are able to cope with
    > documents that could be hundreds of pages long, and therefore its
    > possible.
     
    Well, you may have a document that's hundreds of pages long, but you normally don't have a device that you can draw all those pages onto in a single operation. Normally, you keep those pages in some internal representation for which GDI limitations are irrelevant. You only use GDI calls when it's time to render your data onto the screen or printer, at which point you deal with a reasonably sized rectangle - a screenful or a printer page worth of pixels.
     
    Thus, I can't think of any reason to draw to an HDC using coordinates larger than what can fit on, say, A0 (33" x 47") sheet of paper at 600dpi, which adds up to about 28200 pixels along the larger dimension.
     
    > As i understand the CDC is something of a canvas which
    > windows 'paints' too   I suspect i'm coming up against a limit in the
    > size of that canvas, and wondered how those programs i just mentioned
    > overcame that issue   Do they have multiple canvases
     
    They only render to an HDC the portion of their data that a user can actually see. They never bother rendering the data that's outside the screen or printed page. Why do you
    --
    With best wishes,
        Igor Tandetnik

  • BringerOD

    Please eloborate.  No overflow
    All we have is

    if the page size exceeds 32000 in the y component then

    CSize size;
    size.cy = 32000;
    dc.SetWindowExt ( size);
    dc.SetViewportExt(size);

    I dont know how overflow could come into that

    Will

  • Big Ben

    Thanks for your help on this


  • CDC Issue