Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GR32_Image.pas : ScrollToCenter(X,Y : Integer) is not working properly #35

Closed
chulwoongjeon-stemcell opened this issue Jan 30, 2018 · 7 comments

Comments

@chulwoongjeon-stemcell
Copy link

If the image was zoom-in if the image moves to the other area, then the new area is not updated properly.

@CWBudde
Copy link
Contributor

CWBudde commented Jan 4, 2019

Thanks for reporting. However, to increase the chance to get this fixed, it would be nice if you could supply some code to expose this issue

@lamdalili
Copy link
Contributor

this happens when you are not drawing directly on the bitmap, the use of a new event like OnScaleShiftChange is needed...
proposed code:

TGLayer=class(TBitmapLayer)
...
end;

procedure TGLayer.Changed;
begin
  _Changed:=True;
  inherited;
end;

procedure TGLayer.Paint(Buffer: TBitmap32);
begin
if _Changed then
begin
    DrawPolys; // Draw bitmap for new size
   _Changed:=False;
end;

procedure TGLayer. DrawPolys;
var
  H,W:integer;
  t:TArrayOfArrayOfFloatPoint;
  ScaleX, ScaleY: TFloat;
  B:TFloatRect;
begin
  LayerCollection.GetViewportScale(ScaleX, ScaleY);
  with GetAdjustedRect(Location) do
  begin
    t:=GR32_VectorUtils.ScalePolyPolygon(Src,ScaleX, ScaleY);
    W:=Ceil(Abs(Right-Left));
    H:=Ceil(Abs(Bottom-Top));
    Bitmap.DrawMode:=dmBlend;
    Bitmap.BeginUpdate;
    Bitmap.SetSize(W,H);
    Bitmap.Clear(0);
    PolyPolylineFS(Bitmap,t,clBlack32,False);
    Bitmap.EndUpdate;
  end;
end;

and add this code to TImgView32.DoScaleChange

procedure TImgView32.DoScaleChange;
var
I:integer;
begin
  inherited;
  Buffer.BeginUpdate;
    for I := 0 to Layers.Count - 1 do
       Layers.Items[I].Changed();
  Buffer.EndUpdate();
end;

@chulwoongjeon-stemcell chulwoongjeon-stemcell changed the title GS32_Image.pas : ScrollToCenter(X,Y : Integer) is not working properly GR32_Image.pas : ScrollToCenter(X,Y : Integer) is not working properly May 29, 2019
@chulwoongjeon-stemcell
Copy link
Author

I tried to roll back the 'GR32_Image.pas' to Aug 30, 2012 version.
The version in Aug 2012 didn't show any problem.

@andersmelander
Copy link
Member

@chulwoongjeon-stemcell I have reviewed the changes made to GR32_Image from august 30 to now and as far as I can tell none of those changes should make a difference with regard to this issue.
I really do think we will need a minimal example that reproduces the problem, like Christian requested, in order to get this problem fixed.

@lamdalili I don't understand you comment.

  • Where and when should your proposed OnScaleShiftChange event be fired?
  • TImgView32 just exposes the design-time properties of TCustomImgView32 as published and is not the place to fix things.
    Are you saying that the following would fix the problem (I've rearranged things a bit):
procedure TCustomImgView32.DoScaleChange;
var
  i: integer;
begin
  inherited;
  InvalidateCache;
  UpdateScrollBars;

  BeginUpdate; // Defer premature Changed and Invalidate in UpdateImage
  try
    UpdateImage;

    Buffer.BeginUpdate;
    try
      for i := 0 to Layers.Count - 1 do
        Layers[i].Changed;
    finally
      Buffer.EndUpdate;
    end;
  finally
    EndUpdate;
  end;
  Changed; // Calls Invalidate
end;

@lamdalili
Copy link
Contributor

Yes your code words for me... I use the above example to create new image for different resolutions

I proposed a new event 'OnScaleShiftChange' because some thing is wrong when using changed in line Layers[i].Changed .. here we force raising a possible heavy opeartions and when the scale changed is not the probleme of the Layer but it must be notified and see if any updating is needed.

  for i := 0 to Layers.Count - 1 do
    Layers[i].OnScaleShiftChange;

@andersmelander
Copy link
Member

I will implement the DoScaleChange modification I listed above as a solution for this issue (although I can't reproduce the problem).

With regard to your OnScaleShiftChange it may have merits but it's out of scope for the this release. I have create a new issue for it instead: #89.

@andersmelander
Copy link
Member

Never got an example of what the problem was, so nothing to do here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants