View Issue Details

IDProjectCategoryView StatusLast Update
0000131JEDI VCL00 JVCL Componentspublic2002-07-01 12:53
ReporterremkobonteAssigned Touser72 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionwon't fix 
Product Version 
Target VersionFixed in Version 
Summary0000131: TJvSpecialImage: design time settings applied twice.
DescriptionSet 'if csLoading in ComponentState then Exit;' or so as the first line of ApplyChanges; otherwise, settings set at design time , such as Brightness or Mirrored will be applied twice.
Additional InformationWhat should procedure Reset do, if you make design-time changes? Set it to the original before the design-time changes? Or if you make run-time changes, set it to the image after the design-time changes? It's implemented as the last, but I think it should be the first.

Maybe rename FOriginal to FAltered, apply changes to FAltered; override the paint and draw the FAltered image to the TJvSpecialImage canvas; so the original image will be stored.
TagsNo tags attached.

Activities

user72

2002-06-22 05:21

  ~0000113

Works on my W2K, D6SP2 setup

remkobonte

2002-06-22 07:10

developer   ~0000114

The image specified by TJvSpecialImage.Picture is stored in the unit's dfm file. If you alter Brightness of Mirrored at design-time, then the image specified by TJvSpecialImage.Picture is changed. So, at run-time, if you call Reset, you get the altered image, not the original before the design-time changes.

You could change TJvSpecialImage, so that the image specified by TJvSpecialImage.Picture is never altered by Brightness, Mirrored etc. This could be done by only applying these changes to FOriginal, override the paint and draw the FOriginal image to the TJvSpecialImage canvas, instead of the image specified by TJvSpecialImage.Picture.

user72

2002-06-22 07:15

  ~0000115

OK, now I get it. This presumes that this is the behaviour intended: if Reset was intended to reset the image to the design-time state, then adding "if csLoading in ComponentState" to ApplyChanges should be sufficient, right?

user72

2002-06-22 07:32

  ~0000116

How about the following changes:

1. First row of ApplyChanges:
  if (csLoading in ComponentState) or (csDestroying in ComponentState) then
    Exit;
2. First line of Destroy;
  if not FOriginal.Empty then
    Picture.Assign(FOriginal);
  ...
3. PictureChanged:
...
  if FWorking = False then
  begin
    if FOriginal.Empty then // assign original
      FOriginal.Assign(Picture.Bitmap);
    SetBright(FBright);
  end;
  Invalidate;
...

Wouldn't these changes solve the problems with resetting to original as you originally proposed?


remkobonte

2002-06-22 07:36

developer   ~0000117

Last edited: 2002-06-22 07:37

[Reply to 7:15] No :) If you set Mirrored/Flipped to True at design-time there is a problem.

Now the image specified by FOriginal is mirrored at run-time. If you set Mirrored to False at run-time, the image should be mirrored; If you set Mirrored to True at design-time, nothing should be done (FOriginal is already mirrored). But in the ApplyChanges the image is mirrored/flipped only if Mirrored/Flipped = true.

edited on: 06-22 07:37

edited on: 06-22 07:37

user72

2002-06-22 08:53

  ~0000118

So, better then to make Reset reset to the original image (see my note 7:32) before any design-time or run-time changes?

remkobonte

2002-06-22 09:18

developer   ~0000119

If you apply [7:32] then it seems that you can set the image only once at design-time. [with property Picture in the object-inspector]

user72

2002-06-22 09:26

  ~0000120

Maybe need to override the Picture property too and set FOriginal.Empty := true there...

remkobonte

2002-06-22 09:44

developer   ~0000121

Last edited: 2002-06-22 09:50

Oke, but what do you think should happen, when Reset is called. Reset the image to the image *before* or *after* the design-time settings?

After: then properties Brightness, Mirrored etc should be set to 100, False etc. after create, without changing the stored - desingtime changed - image, I think.

Before: I think the best way to do this, is the same as property Stretched etc. Only apply these changes [Mirrored etc.] when the paint method is called, and don't change the original image. Because this gives flickering, you use double-buffering. So apply the changes to a buffer and draw the buffer on the canvas in the Paint method.

edited on: 06-22 09:50

user72

2002-06-22 10:03

  ~0000122

I think that Reset should reset everything to the way the original image was, i.e as it appears "on disk". When a new image is assigned, the current settings of the Mirrored, Flipped etc properties should be applied to the new image.

I tested with applying the changes as noted in [7:32] and then overrode the Picture property like this:

property Picture:TPicture read GetPicture write SetPicture;
...

procedure TJvSpecialImage.SetPicture(const Value: TPicture);
begin
  FOriginal.Free;
  FOriginal := TBitmap.Create;
  inherited Picture := Value;
end;

Recreating FOriginal ensures that FOriginal is assigned in PictureChanged (Empty is true).I also changed PictureChanged, like this:


  if FWorking = False then
  begin
    if FOriginal.Empty then // assign original
      FOriginal.Assign(Picture.Bitmap);
    ApplyChanges;
  end;
  Invalidate;

Try it out and tell me what you think

remkobonte

2002-06-22 10:21

developer   ~0000123

If you set Brightness to 50 at designtime, and run it's correct [Brightness isn't applied twice and property Brightness = 50] But if you call Reset, only the value of Brightness is changed, not the actual image.

If you set Flipped to True at designtime, and run it's correct; Property Flipped is True; If you then set Flipped to False at runtime, nothing changes. if you then set Flipped to True at runtime, the image is flipped.

user72

2002-06-22 22:57

  ~0000124

Thinking about this some more, this should be all that is needed:

1.When loading a new image, store the original in a hidden image (new Picture property)
2. When Reset is called, set all properties to false, 100 etc and assign the hidden image to the visible one
3. just before destroying, replace the published image with the hidden so the original get's saved (Destroy)

No need to mess about with PictureChanged and checking FOriginal.Empty etc.

Also, FOriginal should be of type TPicture, not TBitmap as that would allow storing and manipualting other types (like jpg and png etc)

user72

2002-06-26 12:46

  ~0000134

I hav emade the changes in the restcured code and further testing should be done against that version

Issue History

Date Modified Username Field Change