views:

618

answers:

1

I am working on a 'print preview' facility to show an overview of a slide with rectangular arrays of sample spots on it.

The slides typically measure 25 x 75 mm and the spot samples are typically 0.1 mm in diameter. There is usually a 2mm gap around the perimeter of the slide where no spots are printed.

The distance between spots (pitches) is accurate to 0.01mm. Pitches of 0.20 and 0.29 mm for example would need to differentiated in the pixels. Representing the spots themselves, 100% accuracy is probably not crucial at this stage as long as the spots are visible and don't overlap.

I would appreciate advice on what techniques to use in order to create a bitmap representation of the slide/spots and to view the slide layout using arbitrary levels of magnification.

This does not have to be sophisticated - a 1:1 representation plus a smaller and larger magnification to start with. I probably cannot zoom out too much as the spots will become too small to be represented.

For larger magnifications I will probably need to know about implementing horizontal / vertical scroll controls as well, but I will tackle this later.

I would like to find out about any programming and scaling techniques that I should be aware of in order to properly implement a zoom facility. I have recently been playing with the StretchBlt function to alter image sizes and it seems ok, however any other relevant information would be useful.

Cheers.

+1  A: 

Let's start from the beginning:

  • why aren't you using ::AFXPrintPreview() and the rest of the print preview facilities of MFC?

  • 'slides' and 'spots' are specific to your industry I think - are they relevant to the question or is it just for illustration?

  • StretchBlt() isn't going to do you much good because it will only let you do pixel-level 'zooming', what you need is to draw a certain part of your control with a higher level of precision. Even if you're not going to use the MFC print preview stuff, have a look at it to see how it can be done.

  • Windows control have all the functionality you need for scrolling and scaling. They are in the device context: SetWindowExt(), SetViewportExt(), SetViewportOrg() etc. Look under 'Coordinate Functions' of the 'CDC Members' page of MSDN. That being said, I have once implemented zooming and scrolling 'manually', by keeping track of the scrollbar position, zooming commands of my control, etc. It was a pain in the ass and looking back, I should have used the Windows facilities. They aren't easy to use either, though, that why I thought I could do it better myself in the first place - turns out I was wrong :)

  • Finally, although I can't tell for sure from your question if you're really in that boat, don't think in terms of physical distances (millimeters etc). The first thing you want to get right is to draw the shape onto the screen, with the right proportions between the elements. Then you want to zoom in/out. Finally, it's only when you get to the printing part that physical measures come into play. The only thing you need to figure out there (slightly simplifying here) is 'what is the correct zoom ratio I need to get the required output'. This is a bit tricky but has very little to do with what seems to be the first part of your question (how to draw your component to the screen).

If you're having troubles, don't hesitate to post more specific questions. I have print preview and printing code here as an example of the 'generic' parts of the printing process, although the specifics are obviously different for every application.

Roel