Page 1 of 1

Change picture to hot-picture when resizing ?

Posted: Tue Sep 27, 2005 9:04 pm
by Stef
For html pages you often include large pictures,
which are shown smaller in the document,
and when you click on it, you get the picture in full size.

It would be nice when you make a (large) picture smaller,
that the picture would change automatically to a hot picture
(linked to the orginal picture location).

Is this possible ?

thanks,

Posted: Wed Sep 28, 2005 7:33 am
by Sergey Tkachenko
No, you need to do it yourself.

But usually HTML pages includes not a scaled large picture but a smaller version of picture.

Posted: Wed Sep 28, 2005 7:40 am
by Stef
1.
ok, I'll do it myself,
is there some event, when a picture is resized with the mouse cursor ?

2.
Apperently I expressed myself wrong,
because that's exactly what I mean ;-)

thanks,[/quote]

Posted: Wed Sep 28, 2005 8:26 am
by Sergey Tkachenko
Sorry, there is no such event.
If you want to convert scaled pictures automatically, I think it's better to do it for all pictures in the document just before HTML saving.

Posted: Sun Oct 02, 2005 7:38 pm
by Stef
I used the onSaveItemToFile event,
and the implementation (shown below) is very straight forward.
It only adds hotspot information if image is resized.

cheers,


procedure Tform_rve_edit.RVESaveItemToFile(Sender: TCustomRichView;
const Path: String; RVData: TCustomRVData; ItemNo: Integer;
SaveFormat: TRVSaveFormat; Unicode: Boolean; var OutStr: String;
var DoDefault: Boolean);
(*******************************************************************************
*******************************************************************************)
var
filnam :string;
gr :tgraphic;
s :string;
tag :integer;
Valign :trvValign;
w,h :integer;
begin
if (RVData.GetItemStyle(ItemNo)=rvsPicture) or
(RVData.GetItemStyle(ItemNo)=rvsHOTpicture) then
begin
if SaveFormat=rvsfHTML then
begin
TCustomRichViewEdit(Sender).GetPictureInfo(ItemNo,filnam,gr,VAlign,Tag);
filnam:=ExtractRelativePath(This_Filename,filnam);
TCustomRichViewEdit(Sender).GetItemExtraIntProperty(ItemNo,rvePimagewidth,w);
TCustomRichViewEdit(Sender).GetItemExtraIntProperty(ItemNo,rvePimageheight,h);
if (gr.Width<>w) or (gr.Height<>h) then
begin
outstr:='<a href="'+filnam+'">'+
'<img width='+inttostr(w)+' height='+inttostr(h)+
' alt=""'+
' src="'+filnam+'"></a>';
dodefault:=false;
end;
end;
end;
end;

Posted: Sun Oct 02, 2005 7:39 pm
by Stef
terrible layout :-(

is there a way to improve that,
or isn't it even allowed to post code snippets ?

cheers,

Posted: Sun Oct 02, 2005 8:32 pm
by Sergey Tkachenko
Select the text and press Code button.
Text between [code] and [/code] is formated using monospaced font.

Posted: Sun Oct 02, 2005 8:49 pm
by Stef
ok, new try

Code: Select all

procedure Tform_rve_edit.RVESaveItemToFile(Sender: TCustomRichView;
  const Path: String; RVData: TCustomRVData; ItemNo: Integer;
  SaveFormat: TRVSaveFormat; Unicode: Boolean; var OutStr: String;
  var DoDefault: Boolean);
(*******************************************************************************
*******************************************************************************)
var
  filnam :string;
  gr     :tgraphic;
  s      :string;
  tag    :integer;
  Valign :trvValign;
  w,h    :integer;
begin
  if (RVData.GetItemStyle(ItemNo)=rvsPicture) or
     (RVData.GetItemStyle(ItemNo)=rvsHOTpicture) then
  begin
    if SaveFormat=rvsfHTML then
    begin
      TCustomRichViewEdit(Sender).GetPictureInfo(ItemNo,filnam,gr,VAlign,Tag);
      filnam:=ExtractRelativePath(This_Filename,filnam);
      TCustomRichViewEdit(Sender).GetItemExtraIntProperty(ItemNo,rvePimagewidth,w);
      TCustomRichViewEdit(Sender).GetItemExtraIntProperty(ItemNo,rvePimageheight,h);
      if (gr.Width<>w) or (gr.Height<>h) then
      begin
        outstr:='<a href="'+filnam+'">'+
                '<img width='+inttostr(w)+' height='+inttostr(h)+
                ' alt=""'+
                ' src="'+filnam+'"></a>';
        dodefault:=false;
      end;
    end;
  end;
end;

Posted: Tue Oct 11, 2005 9:32 pm
by Stef
Correction:

everywhere where "TCustomRichViewEdit(Sender)" is used,
this should be replaced by "RVData",
otherwise it goes wrong if images are in tables.


cheers,

Posted: Wed Oct 12, 2005 8:31 pm
by Stef
Correction2:

This shouldn't be done of course with a hotpicture ;-)