Board index » delphi » Best library to make a photoshop like software

Best library to make a photoshop like software


2005-05-18 08:14:02 PM
delphi188
Hello,
what is the best library today to make a photoshop like software.
I'm more interested by drawing routines, selection tools, layers,
filters,...
I'm not interested in managing many file format.
any idea?
thanks
John
 
 

Re:Best library to make a photoshop like software

Hi John,
Please try our DtpDocuments component:
www.simdesign.nl/dtpdocuments.html
I'm also working on a follow-up, codename "Pyro", which is much more
powerful for vector graphics.
Kind regards,
Nils Haeck
www.simdesign.nl
"John" <XXXX@XXXXX.COM>writes
Quote
Hello,

what is the best library today to make a photoshop like software.
I'm more interested by drawing routines, selection tools, layers,
filters,...
I'm not interested in managing many file format.

any idea?

thanks

John


 

Re:Best library to make a photoshop like software

Quote
what is the best library today to make a photoshop like software.
I'm more interested by drawing routines, selection tools, layers,
filters,...
While there are some commercial libraries around, you should take a look
at the free Graphics32 library at www.g32.org
AFAIK Jon Lennart Aasenden is working on such a library as well, but it
seems he hasn't finished it yet (really looking forward to see it).
But when writing a bitmap editing software, handling bitmaps is the main
focus of your software. And IMO sometimes it makes sense to write your
own library for the main focus of a software (I have written such a
library because I wasn't confident with the memory management of
Graphics32 - now I have a bitmap library with its own memory manager,
allowing to work with bitmaps of an overall size up to the free space on
your hard disks, much like the Photoshop scratch disks - it is not as
difficult as it sounds like).
Jens
 

Re:Best library to make a photoshop like software

this seems to be great (and free):
studio.imagemagick.org/script/index.php
Stef Mientki
John writes:
Quote
Hello,

what is the best library today to make a photoshop like software.
I'm more interested by drawing routines, selection tools, layers,
filters,...
I'm not interested in managing many file format.

any idea?

thanks

John


 

Re:Best library to make a photoshop like software

Hi Jens
Would you share some information about this ? Im eager to know what youve
done
Best Regards
X
"Jens Gruschel" <XXXX@XXXXX.COM>writes
Quote
>what is the best library today to make a photoshop like software.
>I'm more interested by drawing routines, selection tools, layers,
>filters,...

While there are some commercial libraries around, you should take a look
at the free Graphics32 library at www.g32.org

AFAIK Jon Lennart Aasenden is working on such a library as well, but it
seems he hasn't finished it yet (really looking forward to see it).

But when writing a bitmap editing software, handling bitmaps is the main
focus of your software. And IMO sometimes it makes sense to write your
own library for the main focus of a software (I have written such a
library because I wasn't confident with the memory management of
Graphics32 - now I have a bitmap library with its own memory manager,
allowing to work with bitmaps of an overall size up to the free space on
your hard disks, much like the Photoshop scratch disks - it is not as
difficult as it sounds like).

Jens
 

Re:Best library to make a photoshop like software

Thanks Jens for your reply,
Quote
While there are some commercial libraries around, you should take a look
at the free Graphics32 library at www.g32.org
the main problem of G32 is that the visual component is quite poor (no
selection tool, refreshing problem with huge picture (resample the whole
bitmap32 if you modify only a small part))
Quote
AFAIK Jon Lennart Aasenden is working on such a library as well, but it
seems he hasn't finished it yet (really looking forward to see it).
I was waiting for it also but nothing seems to come up...
Quote
But when writing a bitmap editing software, handling bitmaps is the main
focus of your software. And IMO sometimes it makes sense to write your own
library for the main focus of a software (I have written such a library
because I wasn't confident with the memory management of Graphics32 - now
I have a bitmap library with its own memory manager, allowing to work with
bitmaps of an overall size up to the free space on your hard disks, much
like the Photoshop scratch disks - it is not as difficult as it sounds
like).
any plan to sell it?
thanks
John
 

Re:Best library to make a photoshop like software

Nils,
I think DTP document could be interested for making a software like
powepoint or illustrator, I mean for managing vectorial object.
I'm not sure it will help a lot for making a retouching software....
thanks
John
 

Re:Best library to make a photoshop like software

Quote

what is the best library today to make a photoshop like software.
I'm more interested by drawing routines, selection tools, layers,
filters,...
I'm not interested in managing many file format.

any idea?

I recently start to use ImageEn from www.hicomponents.com
For now seems to be good.
Giorgio.
 

Re:Best library to make a photoshop like software

Agreed, but I didn't know exactly what you meant by "photoshop software" :)
DtpDocuments does have layers and filtering effects though.
Nils
"John" <XXXX@XXXXX.COM>schreef in bericht
Quote
Nils,

I think DTP document could be interested for making a software like
powepoint or illustrator, I mean for managing vectorial object.
I'm not sure it will help a lot for making a retouching software....

thanks

John


 

Re:Best library to make a photoshop like software

Quote
any plan to sell it?
Too incomplete to sell it. Basically my bitmaps have a canvas, something
like scanline to access them directly, and a couple of drawing routines
using direct pixel access (like filling a rectangle or circle, or
drawing / stretching one of my bitmaps to another one with optional
alpha blending). Things like drawing polygons are completely missing
(can only be done with the GDI using the canvas property). That's
because I don't concentrate on finishing this library, but add things
from time to time when I need it. Graphics32 is much more complete.
Jens
 

Re:Best library to make a photoshop like software

Quote
Would you share some information about this ? Im eager to know what youve
done
The key is using memory mapped files and some "manager", which holds a
list of bitmaps mapped into memory, removing some of them in a more or
less intelligent way, if new bitmaps are mapped into memory.
Disadvantage: before accessing such a bitmap directly (which might
already be mapped into memory, or might not), you have to "lock" the
bitmap somehow (I am using two methods BeginAccess / EndAccess), similar
to using managed direct draw surfaces. that is because the "manager" has
to know which bitmaps are used when deciding which one unmap. So all of
my routines look like this one (PegtopCopyBitmapAlphaBlend32 is a
routine which uses direct pixel access):
procedure TPegtopCustomBitmap.Blend(const Source: TPegtopCustomBitmap;
DestRect: TRect; SourceX, SourceY: Integer; const Alpha: Integer = 256);
begin
if PegtopClipDestRect(FWidth, FHeight, DestRect, SourceX, SourceY)
then begin
if PegtopClipSourceRect(Source.Width, Source.Height, DestRect,
SourceX, SourceY) then begin
BeginAccess;
try
Source.BeginAccess;
try
PegtopCopyBitmapAlphaBlend32(Origin, Pitch, DestRect,
Source.Origin, Source.Pitch, SourceX, SourceY, Alpha);
finally
Source.EndAccess;
end;
finally
EndAccess;
end;
end;
end;
end;
Such drawing methods are part of the abstract base class, which allows
to use them on all kinds of bitmaps (not only the ones I called "managed").
Here is some other code which might give you some ideas (just some
fragments copied from different locations inside of my units, worthless,
except if you are about to write a similar library, and all of you who
do are welcome to be inspired):
procedure TPegtopCustomBitmap.SetSize(AWidth, AHeight: Integer);
begin
if AWidth < 0 then AWidth := 0;
if AHeight < 0 then AHeight := 0;
if (AWidth <>FWidth) or (AHeight <>FHeight) then begin
if (FWidth>0) and (FHeight>0) then begin
if (FAccessLevel>0) or FAccessWarrant then RefuseAccess;
ReleaseBitmap;
end;
FWidth := AWidth;
FHeight := AHeight;
FBytesPerPixel := 4;
FPitch := FWidth * FBytesPerPixel;
FSize := FPitch * FHeight;
with FBitmapInfo.bmiHeader do begin
biWidth := FWidth;
biHeight := -FHeight;
end;
if (FWidth>0) and (FHeight>0) then begin
try
AllocateBitmap;
except
FWidth := 0;
FHeight := 0;
FOrigin := NIL;
FPitch := 0;
FSize := 0;
raise;
end;
if (FAccessLevel>0) or FAccessWarrant then GrantAccess;
end;
end;
end;
procedure TPegtopCustomBitmap.BeginAccess;
begin
Inc(FAccessLevel);
if (FAccessLevel = 1) and (not FAccessWarrant) and (not Empty) then
GrantAccess;
end;
procedure TPegtopCustomBitmap.EndAccess;
begin
if FAccessLevel>0 then begin
if (FAccessLevel = 1) and (not FAccessWarrant) and (not Empty) then
RefuseAccess;
Dec(FAccessLevel);
end;
end;
procedure TPegtopCustomBitmap.GrantAccess;
begin
end;
procedure TPegtopCustomBitmap.RefuseAccess;
begin
end;
procedure TPegtopCustomBitmap.SetAccessWarrant(Value: Boolean);
begin
if FAccessWarrant <>Value then begin
FAccessWarrant := Value;
if FAccessWarrant then begin
if (FAccessLevel = 0) and (not Empty) then GrantAccess;
end
else begin
if (FAccessLevel = 0) and (not Empty) then RefuseAccess;
end;
end;
end;
procedure TPegtopCustomBitmap.DrawTo(const DC: HDC; DestRect,
SourceRect: TRect);
begin
if not Empty then begin
StretchDIBits(
DC,
DestRect.Left, DestRect.Top, DestRect.Right - DestRect.Left,
DestRect.Bottom - DestRect.Top,
SourceRect.Left, SourceRect.Top, SourceRect.Right -
SourceRect.Left, SourceRect.Bottom - SourceRect.Top,
FOrigin, FBitmapInfo, DIB_RGB_COLORS, SRCCOPY);
end;
end;
procedure TPegtopHandleBitmap.AssignGraphic(Graphic: TGraphic;
BackgroundColor: Longword = $00FFFFFF);
begin
SetSize(Graphic.Width, Graphic.Height);
BeginAccess;
try
Canvas.Draw(0, 0, Graphic);
ReleaseCanvas;
if IsCompletelyTransparent(BoundsRect) then
MaskRect(BoundsRect, TPegtopColor(BackgroundColor),
PegtopColor($FF000000));
finally
EndAccess;
end;
end;
procedure TPegtopHandleBitmap.HandleChanged;
begin
ReleaseCanvas;
end;
procedure TPegtopHandleBitmap.ReleaseCanvas;
begin
if FCanvas <>NIL then begin
if FCanvas.Handle <>0 then DeleteDC(FCanvas.Handle);
FCanvas.Handle := 0;
FCanvas.Free;
FCanvas := NIL;
end;
end;
function TPegtopHandleBitmap.HasHandle: Boolean;
begin
Result := FHandle <>0;
end;
procedure TPegtopHandleBitmap.ReleaseHandle;
begin
if FHandle <>0 then begin
DeleteObject(FHandle);
FHandle := 0;
HandleChanged;
end;
end;
function TPegtopHandleBitmap.GetCanvas: TCanvas;
var
DC: THandle;
begin
if FCanvas = NIL then begin
DC := CreateCompatibleDC(0);
if DC = 0 then raise EPegtopBitmapError.Create('Device context
cannot be created.');
if SelectObject(DC, GetHandle) = 0 then begin
DeleteDC(DC);
raise EPegtopBitmapError.Create('Bitmap cannot be selected into
the specified device context.');
end;
FCanvas := TCanvas.Create;
FCanvas.Handle := DC;
end;
Result := FCanvas;
end;
function TPegtopHandleBitmap.GetHandle: THandle;
begin
if FHandle = 0 then FHandle := CreateHandle;
Result := FHandle;
end;
function TPegtopDeviceBitmap.CreateHandle: THandle;
begin
Result := CreateDIBSection(0, FBitmapInfo, DIB_RGB_COLORS,
Pointer(FOrigin), 0, 0);
end;
procedure TPegtopDeviceBitmap.AllocateBitmap;
begin
try
FHandle := CreateHandle;
if FOrigin = NIL then raise EPegtopBitmapError.Create('DIB handle
cannot be allocated.');
finally
HandleChanged;
end;
end;
procedure TPegtopDeviceBitmap.ReleaseBitmap;
begin
ReleaseCanvas;
ReleaseHandle;
end;
function TPegtopDeviceBitmap.Empty: Boolean;
begin
Result := (FHandle = 0) or inherited Empty;
end;
type
TPegtopFileMappedBitmap = class(TPegtopHandleBitmap)
private
FScratchBlock: TPegtopScratchBlock;
FMemoryMappedFile: TPegtopMemoryMappedFile;
protected
function CreateHandle: THandle; override;
procedure ReleaseBitmap; override;
procedure AllocateBitmap; override;
public
procedure ReleaseCanvas; override;
procedure GrantAccess; override;
procedure RefuseAccess; override;
end;
TPegtopManagedBitmap = class(TPegtopFileMappedBitmap)
public
procedure GrantAccess; override;
procedure RefuseAccess; override;
end;
function TPegtopFileMappedBitmap.CreateHandle: THandle;
var
Dummy: Pointer;
begin
if FScratchBlock <>NIL then begin
Result := CreateDIBSection(0, BitmapInfo, DIB_RGB_COLORS, Dummy,
FScratchBlock.Handle, FScratchBlock.Offset);
end
else begin
Result := CreateDIBSection(0, BitmapInfo, DIB_RGB_COLORS, Dummy,
FMemoryMappedFile.Handle, 0);
end;
end;
procedure TPegtopFileMappedBitmap.ReleaseCanvas;
begin
inherited; // release canvas
// handle to dib section isn't needed any more, too
// (we still have pixel data in memory mapped file)
ReleaseHandle;
end;
procedure TPegtopFileMappedBitmap.ReleaseBitmap;
begin
if FScratchBlock <>NIL then begin
FScratchBlock.Deallocate;
FScratchBlock := NIL;
end
else begin
FMemoryMappedFile.Free;
end;
end;
procedure TPegtopFileMappedBitmap.AllocateBitmap;
begin
FScratchBlock := BitmapScratchFiles.Allocate(Size);
if FScratchBlock = NIL then begin
FMemoryMappedFile := TPegtopMemoryMappedFile.Create('', Size);
end;
HandleChanged;
end;
procedure TPegtopFileMappedBitmap.GrantAccess;
var
Success: Boolean;
begin
Success := False;
while not Success do begin
try
if FScratchBlock <>NIL then begin
DefineOrigin(FScratchBlock.MapView);
end
else begin
DefineOrigin(FMemoryMappedFile.MapView);
end;
Success := True;
except
if not BitmapMemoryManager.RemoveEldest then raise;
end;
end;
end;
procedure TPegtopFileMappedBitmap.RefuseAccess;
var
P: Pointer;
begin
P := Origin;
DefineOrigin(NIL);
if FScratchBlock <>NIL then begin
FScratchBlock.UnmapView;
end
else begin
FMemoryMappedFile.UnmapView(P);
end;
end;
procedure TPegtopManagedBitmap.GrantAccess;
begin
BitmapMemoryManager.Add(Self);
inherited;
end;
procedure TPegtopManagedBitmap.RefuseAccess;
begin
inherited;
BitmapMemoryManager.Remove(Self);
end;
Jens