Page 1 of 1

File is too big when i pasted some pictures from ClipBoard

Posted: Thu Sep 08, 2016 4:11 am
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.

Posted: Thu Sep 08, 2016 7:33 am
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...

Posted: Tue Sep 20, 2016 12:52 pm
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.

Posted: Wed Sep 28, 2016 2:28 pm
by Sergey Tkachenko
WheelStep is fixed. In the last update, larger values of ViewProperty.WheelStep increase scrolling speed.