Change picture to hot-picture when resizing ?

General TRichView support forum. Please post your questions here
Post Reply
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Change picture to hot-picture when resizing ?

Post 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,
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Post 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]
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Post 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;
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Post by Stef »

terrible layout :-(

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

cheers,
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Select the text and press Code button.
Text between [code] and [/code] is formated using monospaced font.
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Post 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;
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Post 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,
Stef
Posts: 90
Joined: Mon Aug 29, 2005 9:56 am
Contact:

Post by Stef »

Correction2:

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