On Monday 25 February 2002 1:36 pm, Asger K. Alstrup Nielsen wrote: > On Mon, 25 Feb 2002, Angus Leeming wrote: > > > void GImageXPM::scale(GParams const & params) > > { > > if (!xpm_image_) > > return; > > > > } > > The principle behind scaling is simple: It's raytracing. > > So, for each destination pixel, calculate which pixel it corresponds > to in the source picture.
Ok, the idea is easy enough. The devil, as they say, is in the detail. For example, what do I do if (say) the x-scaling is 1.2, so the destination pixel corresponds to a weighted average of two source pixels? Do I choose one or the other or weight the result? This latter will result in many more colors. > From this point on, the rest is just optimizations, and you > do not need those for starters. Indeed. GImageXPM is a very simple image loader and manipulation class. I want code that is clear and easy to maintain, so have aimed for simple manipulations only. xformsGImage and qt2GImage will leverage the power of their underlying gui libraries, but that is for the future. > I think you can manage from this point. If not, I can provide > you with the needed bits. > > If you want to make it nice, you also do linear interpolation > in the case of floating source coordinates. > > Help this helps, > > Asger Thanks, Asger. It has indeed helped. However, some sample code would be good! Angus (attempting not to reinvent the wheel if possible).