View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000131 | JEDI VCL | 00 JVCL Components | public | 2002-06-13 16:30 | 2002-07-01 12:53 |
Reporter | remkobonte | Assigned To | user72 | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | won't fix | ||
Product Version | |||||
Target Version | Fixed in Version | ||||
Summary | 0000131: TJvSpecialImage: design time settings applied twice. | ||||
Description | Set '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 Information | What 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. | ||||
Tags | No tags attached. | ||||
|
Works on my W2K, D6SP2 setup |
|
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. |
|
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? |
|
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? |
|
[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 |
|
So, better then to make Reset reset to the original image (see my note 7:32) before any design-time or run-time changes? |
|
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] |
|
Maybe need to override the Picture property too and set FOriginal.Empty := true there... |
|
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 |
|
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 |
|
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. |
|
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) |
|
I hav emade the changes in the restcured code and further testing should be done against that version |