keyongtech


  keyongtech > delphi > 08/2005

 #1  
08-23-05, 05:41 AM
Wayne & Carr
Hello All;

=======
I was at one of the local business here today, and they
Confronted me about an Imaging Software that would
Allow them too Zoom in on an image that is taken
From across a room Image, so that you can zoom in on a certain design on a
painting.
=======

I have been searching the Net for either a Photoshop Plug-in,
Or a Stand-Alone software for "Scaling" Images without Degradation,
I have found a Plug-in for Photoshop that:
[Scale up to 700% without image degradation.]

But what I need is something that will scale higher than this
Without too much degradation of the image?

Can anyone here either suggest a software, or possible
Delphi Component Image Suite that will allow me to do this?

Thanks All;
Wayne
 #2  
08-23-05, 10:25 AM
Jens Gruschel
> But what I need is something that will scale higher than this
> Without too much degradation of the image?


Graphics32 (http://www.g32.org) might be interesting (there are similar
libraries around, but I think Graphics32 is the best free one). it's
only a good choice if you are willing to use TBitmap32, the own bitmap
class of Graphics32 (but you can mix it with TBitmap easily, both of
them have a TCanvas property and there are assign methods). IIRC
Graphics32 has different ways how to resample the image (bilinear,
bicubis etc.). Of course there are many other useful routines for image
processing included (such as drawing operations with alpha blending and
antialiasing).

And there is the resampling library Anders Melander wrote (his website
is down, but I think the project was continued elsewhere). There are
different algorithms included, some of them faster, some of them provide
better quality. It's probably the best resampling library for Delphi, if
you need more than just bilinear resampling (the version I have used
many years ago had a switch which had to be enabled to make it really fast).

Then you can use the WinAPI directly using StretchDIBits, making sure
following code is executed before:
SetStretchBltMode(DC, STRETCH_HALFTONE);
SetBrushOrgEx(DC, 0, 0, NIL);
But I'm not sure whether this will work for every Windows platform
(don't know about Win 9x and NT, read the documentation). And while it's
very fast, quality might not fulfil your wishes, especially since you
cannot control how the resampling is done. But it's really simple to use.

Or write your own routine manipulating the pixel buffer directly (using
the bitmap's ScanLine property). Following routine of mine uses linear
interpolation, which might not be good enough for your needs. You feed
it with Origin := Bitmap.ScanLine[0] and Pitch :=
Integer(Bitmap.ScanLine[1]) - Integer(Origin). No clipping is performed
(but if you need it I can assist you), so make sure the rects you pass
are valid. It's only working for 32 bit images (but can easily be
transformed to work with 24 bit). Of course it's very fast (but doesn't
use MMX, so Graphics32 probably is faster, although I haven't looked at
the source code and did not compare speed) and as accurate as can be
(even more accurate than using floating point arithmetics, since my
version has absolutely no rounding errors, but that's only a theoretical
advantage, since it never has to be that accurate):

procedure PegtopStretchBitmap32(const DestOrigin: Pointer; const
DestPitch: Integer; const DestRect: TRect;
const SourceOrigin: Pointer; const SourcePitch: Integer; const
SourceRect: TRect);
var
X, Y: Integer;
DestP, DestQ: PPegtopColor;
SourceP, SourceQ: PPegtopColor;
DeltaIntX, DeltaFracX: Integer;
DeltaIntY, DeltaFracY: Integer;
SourceWidth, SourceHeight, DestWidth, DestHeight: Integer;
SourceIntX, SourceFracX: Integer;
SourceIntY, SourceFracY: Integer;
begin
// set width and height:
SourceWidth := SourceRect.Right - SourceRect.Left - 1;
SourceHeight := SourceRect.Bottom - SourceRect.Top - 1;
DestWidth := DestRect.Right - DestRect.Left - 1;
DestHeight := DestRect.Bottom - DestRect.Top - 1;
if DestWidth < 1 then DestWidth := 1;
if DestHeight < 1 then DestHeight := 1;
// set deltas:
DeltaIntX := SourceWidth div DestWidth;
DeltaFracX := SourceWidth mod DestWidth;
DeltaIntY := SourceHeight div DestHeight;
DeltaFracY := SourceHeight mod DestHeight;
// set source y-coodinate:
SourceIntY := (DestRect.Top * SourceHeight div DestHeight) +
SourceRect.Top;
SourceFracY := (DestRect.Top * SourceHeight) mod DestHeight;
// set destination pointer:
DestQ := Pointer(Integer(DestOrigin) + DestRect.Top * DestPitch +
DestRect.Left * 4);
for Y := DestRect.Top to DestRect.Bottom - 1 do begin
DestP := DestQ;
// set source x-coordinate:
SourceIntX := (DestRect.Left * SourceWidth div DestWidth) +
SourceRect.Left;
SourceFracX := (DestRect.Left * SourceWidth) mod DestWidth;
// set source pointer:
SourceQ := Pointer(Integer(SourceOrigin) + (SourceIntY shr 8) *
SourcePitch);
for X := DestRect.Left to DestRect.Right - 1 do begin
// set source pointer:
SourceP := SourceQ;
Inc(SourceP, SourceIntX shr 8);
// copy pixel:
DestP^ := SourceP^;
// inc dest pointer
Inc(DestP);
// simulate floating point arithmetics:
Inc(SourceIntX, DeltaIntX);
Inc(SourceFracX, DeltaFracX);
if SourceFracX > DestWidth then begin
Inc(SourceIntX);
Dec(SourceFracX, DestWidth);
end;
end;
// simulate floating point arithmetics:
Inc(SourceIntY, DeltaIntY);
Inc(SourceFracY, DeltaFracY);
if SourceFracY > DestHeight then begin
Inc(SourceIntY);
Dec(SourceFracY, DestHeight);
end;
// next destination line:
DestQ := Pointer(Integer(DestQ) + DestPitch);
end;
end;

Jens
 #3  
08-23-05, 10:30 AM
Jens Gruschel
> Or write your own routine manipulating the pixel buffer directly (using
> the bitmap's ScanLine property). Following routine of mine uses linear
> interpolation, which might not be good enough for your needs. You feed
> it with Origin := Bitmap.ScanLine[0] and Pitch :=
> Integer(Bitmap.ScanLine[1]) - Integer(Origin). No clipping is performed
> (but if you need it I can assist you), so make sure the rects you pass
> are valid.


Forgot to mention: the rect coordinates are scaled by 256 to allow sub
pixel accuracy, so Rect(0, 1, 2.5, 10) has to be passed as Rect(0, 256,
640, 2560).

Jens
 #4  
08-23-05, 08:08 PM
Wayne & Carr
Awsome, Simply Awsome :)

I just downloaded and installed the Components, and went through the
Demo's
And the Full Demo project with the Magnifier, is just what I was after.

In your first Posting, you have the source code for:
PegtopStretchBitmap32

Please explain to me what I would need to do with this please?

Thanks alot for this information, it is great.

Wayne
 #5  
08-23-05, 08:17 PM
John Wester [Group W]
In article <430aa8b6$1>, spam says...
> Hello All;
>
> =======
> I was at one of the local business here today, and they
> Confronted me about an Imaging Software that would
> Allow them too Zoom in on an image that is taken
> From across a room Image, so that you can zoom in on a certain design on a
> painting.
> =======
>
> I have been searching the Net for either a Photoshop Plug-in,
> Or a Stand-Alone software for "Scaling" Images without Degradation,
> I have found a Plug-in for Photoshop that:
> [Scale up to 700% without image degradation.]
>


Don't know if this is the one you are looking for, but people highly
recommend it:

http://www.fredmiranda.com/RP/
 #6  
08-23-05, 09:03 PM
Jens Gruschel
> I just downloaded and installed the Components, and went through the
> Demo's
> And the Full Demo project with the Magnifier, is just what I was after.


Glad to hear that.

> In your first Posting, you have the source code for:
> PegtopStretchBitmap32
>
> Please explain to me what I would need to do with this please?


You probably don't need it if you don't want to do such low level
programming. You can use it the way I told you: obtain a pointer to the
first and second scanline of your bitmap, calculate the difference
between both, and pass the parameters to the procedure. What at first
glance looks a bit complicated is very flexible: I call the procedure
from my own bitmap class (which is similar to Graphics32, has less
features, but better memory management). And I can use the procedure for
Graphics32 bitmaps, DirectX surfaces, and any other 32 bit images. But
as I said: if you don't want to write your own library, it's probably
not useful for you (unless you are searching for a solution which
doesn't involve any third party library).

Jens
 #7  
08-24-05, 08:16 AM
Dan Downs
> I have been searching the Net for either a Photoshop Plug-in,
> Or a Stand-Alone software for "Scaling" Images without Degradation,
> I have found a Plug-in for Photoshop that:
> [Scale up to 700% without image degradation.]


I'm guessing you found Genuine Fractals 4.0 by
http://www.ononesoftware.com/, looks like it was just sold to them this
year, it was lizardtech. I doubt you'll find much that beats this, I've
demoed it a few times over the last 3-4 years and its always worked very
well, but I never really had a need for it, but its pretty cool.

If you do find something better I'd really like to know.

DD
 #8  
08-24-05, 04:52 PM
Wayne & Carr
"Dan Downs" >
> I'm guessing you found Genuine Fractals 4.0 by


Yep, tested it out, rather nice, but you can only go to a certain scale.
But then again, I have not completed tested it as it:

I have not "Cropped" out a section of an image, and tried it that way.
But will here in a few.

----------------------------------
John Wester Wrote
>>Don't know if this is the one you are looking for, but people highly
>>recommend it:
>>[..]


This one looks right promising as well, As it does take the image and zoom
right on it.
I just need to play around with it some more.

------------------------
The Components that [Jens Gruschel] suggested, have some very high
potential.
Of which I will be playing around with on my spare time.

Take Care All
Wayne
Similar Threads
Image Degradation in Placeholders with Bevel Applied

I recently wrote about a problem I am having with PPT 2007 using customized placeholders. The placeholders, when a bevel is applied, degrade the quality of the image...

Scale Image w/o creating a 24 bit image object

Hi, I have a large (1000px x 20000px) Image object that I am trying to scale down. It is in the 8bppIndexed format. I am currently creating a new 24 bit Image object and...

How a color bmp image can be converted to gray scale image ?

Hi all, How can I convert a color bmp image as gray scale image and load it in a dialogbox? Thanks in Advance. Regards Hari

Image rotation in XP Explorer - degradation?

When I try to use Explorer to rotate an image from my 5MP Canon Powershot A95 camera (2592x1944 px), I get the following warning message: "Because of the dimensions of this...

modifying image metadata causes quality degradation?

Hello, The problem is not because of the metadata but because JPEG compression is lossy and unless you save at 100% fidelity you will always degrade the image. If the image...


All times are GMT. The time now is 11:06 PM. | Privacy Policy