Thanks for taking the time to answer my questions. I still have
problems with the class. When loading(is this a bug?)/stretching a
greyscale or indexed tiff image the values of the pixel gets shifted
with 1 down (for example from $FF to $FE) if I use NearestNeighbor as
the interpolation method. Any other method (bicubic or bilinear...)
mangles the data beyond use for me.
I've used the DrawImage(Image,Rectangle,int,int,int,int,GraphicsUnit)
method with pixel as graphicsunit but it doesn't help.
Going through a lot of different tiff images, I've noticed that
Drawing2D.PixelOffsetMode.Half doesn't always help as sometimes it
leaves a transparent line at the right and bottom edges.
As I said earlier, I'm writing some scientific software and if I can't
count on getting out non-mangled images it's of little use continuing.
The only solution I see is programming my own methods with Setpixel
and Getpixel but these are insanely slow! Are there any other
alternatives? I've looked at the "Victor Image Processing Library" but
it's a bit too expensive for me and what I'm doing.
One more question:
image0.setpixel(0,0,color.green)
if image0.getpixel(0,0)=color.green then
......
endif
Why doesn't this work?
If I use
if image0.getpixel(0,0).toargb=color.green.toargb then
then it works. Why is this? What's the point of having to convert a
structure into an integer to get it working?
Thanks,
Linus
[quoted text, click to view] > Thegraphicsclassis very complex but at the same time well thought
> out. You certainly don't need to invent your own method for such a
> simple case and certainly do not mess with getpixel and setpixel unless
> you want the slowestgraphicspossible.
>
> Calculations are al done in single precision floating point. this
> enables the transformation pipeline to work correctly. Integers would be
> too inaccurate.
>
> The pixel offset mode is only to lock the pixel to a specific part of a
> pixel, it won't move the image too far. What's happening is that the
> change in size is causing interpolation which is not always good. Try
> using the bilinear mode instead of the bicubic.
>
> Finally, for the best control, use the
> DrawImage(Image,Rectangle,int,int,int,int,GraphicsUnit) method.
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Ramuseco Limited .NET consulting
http://www.ramuseco.com >
> Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm >
> Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm >
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
> Linus wrote:
> > On Sep 29, 2:26 pm, "Bob Powell [MVP]" <b...@spamkillerbobpowell.net>
> > wrote:
> >> Whenever you resize an image theGraphicsobject needs to reposition the
> >> pixels in a given ratio. The values must eventually be converted to intefers
> >> at some time so rounding losses mean that images can move by a pixel or two.
> >> The PixelOffset.Half mode effectively adds a float value of 0.5 to the
> >> calculation such that the integer rounding goes to the nearest value and is
> >> not automatically rounded down.
>
> >> Your bitmaps are resizing because you're not taking the declared resolutions
> >> of the originals and the default resolution of a new bitmap into account.
> >> When you create a new image you should set the resolution from the old one
> >> or use the DrawImage method that takes specific source and destination
> >> rectangles and uses the "Pixel"graphicsunit.
>
> > So do I understand it correctly that thegraphicsobject being
> > manipulated is always being manipulated in single/double and not
> > integers? And if I use PixelOffset it might shift the image too far in
> > the other direction?
> > I'm trying to use the DrawImage method using the upperleftcorner copy
> > with the pixel graphicsunit and it still resizes it. The DrawImage
> > method is a bit confusing. Are there any resources that describes the
> >graphicsclassin more indepth because the MSDN doesn't do it. Or am I
> > better off using the bitmaps and creating my own methods using
> > getpixel and setpixel?
>
> > Thanks for the help!
>
> > Linus