#1 2011-03-26 09:09:46

Chaa
Member
Registered: 2011-03-26
Posts: 244

TGDIPlusFull

I use SynGdiPlus.pas and SynPdf.pas to create PDF files. And I need the ability to rotate images.
Can you add to the TGDIPlusFull the rest of gdiplus.dll functions, such as
CreateBitmapFromScan0, BitmapLockBits and BitmapUnlockBits?

Offline

#2 2011-03-26 11:48:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: TGDIPlusFull

How do you generate SynPdf files?

Are you using SynGdiPlus to create a bitmap content, then render this bitmap using SynPdf?
If it is the case, it does make sense.

I've added CreateBitmapFromScan0, BitmapLockBits and BitmapUnlockBits methods to TGDIPlusFull.
See http://synopse.info/fossil/info/f09f1b0174

Offline

#3 2011-03-28 02:36:51

Chaa
Member
Registered: 2011-03-26
Posts: 244

Re: TGDIPlusFull

Images acquired from scanner.
Then the images can be reordered and rotated.
To rotate an images, I use SynGdiPlus.

procedure RotateImage(const ASrcImage: THandle; var ADstImage: THandle);
var
    LWidth: Cardinal;
    LHeight: Cardinal;
    LBrush: THandle;
    LGraphics: THandle;
begin
    Gdip.GetImageWidth(ASrcImage, LWidth);
    Gdip.GetImageHeight(ASrcImage, LHeight);
    CheckGdipStatus(Gdip.CreateBitmapFromScan0(LHeight, LWidth, 0, PixelFormat24bppRGB, nil, ADstImage));
    try
        CheckGdipStatus(Gdip.CreateFromImage(ADstImage, LGraphics));
        try
            CheckGdipStatus(Gdip.CreateSolidFill($FFFFFFFF, LBrush));
            try
                CheckGdipStatus(Gdip.FillRectangle(LGraphics, LBrush, 0, 0, LHeight, LWidth));
            finally
                Gdip.DeleteBrush(LBrush);
            end;
            Gdip.RotateTransform(LGraphics, 90);
            Gdip.TranslateTransform(LGraphics, LHeight, 0, 1);
            CheckGdipStatus(Gdip.DrawImageRect(LGraphics, ASrcImage, 0, 0, LWidth, LHeight));
        finally
            Gdip.DeleteGraphics(LGraphics);
        end;
    except
        Gdip.DisposeImage(ADstImage);
        ADstImage := 0;
        raise;
    end;
end;

BitmapLockBits and BitmapUnlockBits used to create black and white images.
P.S.
I join to the wishes expressed in the PDF Engine topic about adding reading PDF files. In order to be able to add or replace scanned pages.

Last edited by Chaa (2011-03-28 02:39:03)

Offline

Board footer

Powered by FluxBB