File is too big when i pasted some pictures from ClipBoard

General TRichView support forum. Please post your questions here
Post Reply
linsoo
Posts: 5
Joined: Wed Sep 07, 2016 5:49 am

File is too big when i pasted some pictures from ClipBoard

Post by linsoo »

Question 1:

I want't to reduce the file size when many pictures were pasted from Clipboard.

Code below worked, the file size is small. But the pictures in file are so distortion:

Code: Select all

procedure TResearchReportFrame.RichViewEdit1Paste(Sender: TCustomRichViewEdit;
  var DoDefault: Boolean);
var
  png : TPngImage;
  gr : TGraphic;
begin
  if Clipboard.HasFormat(CF_BITMAP) then
  begin
    DoDefault := False;
    png := TPngImage.Create;
    png.LoadFromClipboardFormat(CF_BITMAP,ClipBoard.GetAsHandle(CF_BITMAP),0);
    gr := RV_CreateGraphics(TGraphicClass(png.ClassType));
    gr.Assign(png);           
//    png.SaveToFile('d:\1.png');
    RichViewEdit1.ActiveEditor.InsertPicture('',gr, rvvaLeft);
    png.Free;
  end
  else
  begin
    DoDefault := True;
  end;
end;
Is there any way to deal this?

Question 2:

Mouse wheel in TSRichViewEdit is so slow.

If I set this property geater than 10, the mouse wheel will not work.. , Is there any other property?
TSRichViewEdit.ViewProperty.WheelStep
TSRichViewEdit.RichViewEdit.WheelStep
Thanks.
linsoo
Posts: 5
Joined: Wed Sep 07, 2016 5:49 am

Post by linsoo »

Question 2 was solved by this code:

Code: Select all

procedure TResearchReportFrame.RichViewEdit1VScrolled(Sender: TObject);
begin
  if RichViewEdit1.ScrollBarV.Position > OldPosition then
  begin
    RichViewEdit1.ScrollBarV.Position := RichViewEdit1.ScrollBarV.Position + RichViewEdit1.ViewProperty.WheelStep;
  end
  else if RichViewEdit1.ScrollBarV.Position < OldPosition   then
  begin
    RichViewEdit1.ScrollBarV.Position := RichViewEdit1.ScrollBarV.Position - RichViewEdit1.ViewProperty.WheelStep;
  end;
  OldPosition := RichViewEdit1.ScrollBarV.Position;
end;
Although it's not very butilfull...
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1. I cannot see problems with the code.
In my tests, the inserted PNG image looks exactly like the source bitmap.
It's only too complicated, and may be simplified to

Code: Select all

procedure TForm3.SRichViewEdit1Paste(Sender: TCustomRichViewEdit;
  var DoDefault: Boolean);
 var
   png : TPngImage;
 begin
   if Clipboard.HasFormat(CF_BITMAP) then
   begin
     DoDefault := False;
     png := TPngImage.Create;
     png.LoadFromClipboardFormat(CF_BITMAP,ClipBoard.GetAsHandle(CF_BITMAP),0);
     SRichViewEdit1.ActiveEditor.InsertPicture('', png, rvvaAbsMiddle);
   end;
end;
I also changed the image alignment from left to absMiddle.

2. As for mouse wheel, the default setting work fine for me.
However, I can see ViewProperty.WheelStep is processed incorrectly, larger values decrees scrolling speed. It will be fixed in the next update.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

WheelStep is fixed. In the last update, larger values of ViewProperty.WheelStep increase scrolling speed.
Post Reply