does anyone have a solution for picture in report with linked photo instead of stored in db?

would be nice :-)

Thats the solution for me:

procedure frmToDo_cmdToDoSpeichern_OnClick (Sender: TObject; var Cancel: boolean);
begin
    frmToDo.edToDoFoto1.dbImageIsChanged := BildVerkleinern (frmToDo.edToDoFoto1);
end;

function BildVerkleinern (Image: TdbImageDatabase): boolean;
var
    QuellBildName, QuellBildPfad: string;
    ZielBildName, ZielBildPfad: string;
    Querformat: boolean;
    BreiteNeu,HoeheNeu: integer;

begin
    Result := False;
    // ShowMessage ('BreiteVorher=' + IntToStr(Image.Picture.Width) + ' HöheVorher=' + IntToStr(Image.Picture.Height));
    // if Image.dbImageIsChanged then
    begin

        if (Image.Picture.Width > 800) or (Image.Picture.Height > 800) then
            begin
                if Image.Picture.Width > Image.Picture.Height then
                    begin
                        BreiteNeu := 800;
                        HoeheNeu := int(Image.Picture.Height / Image.Picture.Width * 800);
                    end
                else
                    begin
                        HoeheNeu := 800;
                        BreiteNeu := int(Image.Picture.Width / Image.Picture.Height * 800);
                    end;

                QuellBildName := ExtractFileName(Image.dbFileName);
                QuellBildPfad := GetEnvironmentVariable('Temp');

                ZielBildName := '_' + QuellBildName;
                ZielBildName := ChangeFileExt(ZielBildName, '.jpg');
                ZielBildPfad := GetEnvironmentVariable('Temp');


                // ShowMessage('QuellBild=' + QuellBildPfad + '\' + QuellBildName);
                // ShowMessage('ZieBild=' + ZielBildPfad + '\' + ZielBildName);

                Image.Picture.SaveToFile(QuellBildPfad + '\' + QuellBildName);

                //PictureResizeToJpg(InFile, OutJpgFile: string; NewWidth: integer = -1; NewHeight: integer = 1, Quality: integer = 80);

                if PictureResizeToJpg(QuellBildPfad + '\' + QuellBildName, ZielBildPfad + '\' + ZielBildName, BreiteNeu,HoeheNeu,75) then
                    begin
                        //Image.dbImageIsChanged := True;
                        Image.Picture.LoadFromFile(ZielBildPfad + '\' + ZielBildName);
                        ShowMessage ('BreiteNachher=' + IntToStr(Image.Picture.Width) + ' HöheNachher=' + IntToStr(Image.Picture.Height));
                        //DeleteFile(QuellBildPfad + '\' + QuellBildName);
                        //DeleteFile(ZielBildPfad + '\' + ZielBildName);
                        Result := True;
                    end;

            end;
    end;
end;

I have 3 database stored pictures and 1 database stored file in records that I want to pass to the sendmail function as attachment.
I did not fin any example here in the forum. Can anyone help me?

Thanks a lot :-)

I want to use a resize function on different "SaveImageToDataBaseControls".
The procedure on an Butto works fine and so I want to use it in an function fo more then one Imagecontrols.

How can I pass the control to the function?
This function should then be called on saging the record

 
Bildverkleinern (frmAdresse.Foto1)
Bildverkleinern (frmAdresse.Foto2)
Bildverkleinern (frmAdresse.Foto3)

I tried something like this but leads to error:

function BildVerkleinern (Image: TPicture): boolean;
var
    QuellBildName, QuellBildPfad: string;
    ZielBildName, ZielBildPfad: string;
    Querformat: boolean;
    BreiteNeu,HoeheNeu: integer;
begin
    Result := False;
    ShowMessage ('BreiteVorher=' + IntToStr(Image.Picture.Width) + ' HöheVorher=' + IntToStr(Image.Picture.Height));
    // if Image.dbImageIsChanged then
    begin

        if (Image.Picture.Width > 800) or (Image.Picture.Height > 800) then
            begin
                if Image.Picture.Width > Image.Picture.Height then
                    begin
                        BreiteNeu := 800;
                        HoeheNeu := int(Image.Picture.Height / Image.Picture.Width * 800);
                    end
                else
                    begin
                        HoeheNeu := 800;
                        BreiteNeu := int(Image.Picture.Width / Image.Picture.Height * 800);
                    end;

                QuellBildName := ExtractFileName(Image.dbFileName);
                QuellBildPfad := GetEnvironmentVariable('Temp');

                ZielBildName := '_' + QuellBildName;
                ZielBildName := ChangeFileExt(ZielBildName, '.jpg');
                ZielBildPfad := GetEnvironmentVariable('Temp');


                ShowMessage('QuellBild=' + QuellBildPfad + '\' + QuellBildName);
                ShowMessage('ZieBild=' + ZielBildPfad + '\' + ZielBildName);

                Image.Picture.SaveToFile(QuellBildPfad + '\' + QuellBildName);

                //PictureResizeToJpg(InFile, OutJpgFile: string; NewWidth: integer = -1; NewHeight: integer = 1, Quality: integer = 80);

                if PictureResizeToJpg(QuellBildPfad + '\' + QuellBildName, ZielBildPfad + '\' + ZielBildName, BreiteNeu,HoeheNeu,75) then
                    begin
                        Image.dbImageIsChanged := True;
                        Image.Picture.LoadFromFile(ZielBildPfad + '\' + ZielBildName);
                        ShowMessage ('BreiteNachher=' + IntToStr(Image.Picture.Width) + ' HöheNachher=' + IntToStr(Image.Picture.Height));
                        DeleteFile(QuellBildPfad + '\' + QuellBildName);
                        DeleteFile(ZielBildPfad + '\' + ZielBildName);
                        Result := True;
                    end;

            end;
    end;
end;

Is there an easy way to automatic resize pictures to an given resolution (or aspect) when saving the record?
The pictures should be stored inside the database and also used as attachment von sendemail function.
MVD is a wonderfull peace of software and the help here in the forum is a perfect way to learn it.

Thanks a lot!

I have the problem that multiple edit forms are shown if the record-edit ist started with doubleclick on the grid.
If  I close the first edit form then the second one is shown.

This happens if there are more then one edit-buttons defined on then main form.
Is the a way to define which edit form (and only this one) should be shown on grid_doubleclick?

Thanks for help

7

(3 replies, posted in Script)

Thank for quick help :-)
For multiple cc adresses i have to copy and modify the // Recipient Block?

maybe someone can help me.
is it possible to send an email with sendmail to cc recipients.
would be great.