added more "professional" way to "show transparency" :)

+ some bugfixes in renderMT and Fullscreen
This commit is contained in:
zueuk 2006-08-23 15:57:47 +00:00
parent 53e8c17ac2
commit 37a2bc7ad7
8 changed files with 191 additions and 153 deletions

View File

@ -109,9 +109,6 @@ begin
while Renderer <> nil do
Application.ProcessMessages; // HandleThreadTermination kinda should be called here...(?)
// Renderer.Free;
// Renderer := nil;
end;
assert(not assigned(renderer), 'Render thread is still running!?');
@ -160,19 +157,6 @@ procedure TFullscreenForm.HandleThreadTermination(var Message: TMessage);
var
bm: TBitmap;
begin
if Assigned(Renderer) then begin
(*
if not Closing then begin
bm := TBitmap.Create;
bm.assign(Renderer.GetImage);
Image.SetBounds(imgLeft, imgTop, imgWidth, imgHeight);
Image.Picture.Graphic := bm;
bm.Free;
end;
*)
//Renderer.Free;
//Renderer := nil;
end;
RenderStop.Enabled := false;
RenderMore.Enabled := false;

View File

@ -3,7 +3,7 @@ unit ImageMaker;
interface
uses
Windows, Graphics, ControlPoint, RenderTypes;
Windows, Graphics, ControlPoint, RenderTypes, PngImage;
type TPalette = record
logpal : TLogPalette;
@ -47,13 +47,13 @@ type
procedure Progress(value: double);
function GetTransparentImage: TBitmap;
public
constructor Create;
destructor Destroy; override;
function GetImage: TBitmap;
function GetTransparentImage: TPNGObject;
procedure SetCP(CP: TControlPoint);
procedure Init;
@ -74,7 +74,7 @@ type
implementation
uses
Math, SysUtils, PngImage, JPEG, Global, Types;
Math, SysUtils, JPEG, Global, Types;
{ TImageMaker }
@ -181,9 +181,9 @@ end;
///////////////////////////////////////////////////////////////////////////////
function TImageMaker.GetImage: TBitmap;
begin
if ShowTransparency then
Result := GetTransparentImage
else
// if ShowTransparency then
// Result := GetTransparentImage
// else
Result := FBitmap;
end;
@ -312,8 +312,6 @@ begin
//bucketpos := 0;
by := 0;
for i := 0 to fcp.Height - 1 do begin
// if FStop then
// Break;
bx := 0;
Progress(i / fcp.Height);
AlphaRow := PByteArray(FAlphaBitmap.scanline[YOffset + i]);
@ -442,8 +440,7 @@ zero_alpha:
Row[j].red := ri;
Row[j].green := gi;
Row[j].blue := bi;
AlphaRow[j] := ai; //?
AlphaRow[j] := ai;//?
end
end;
@ -531,49 +528,25 @@ begin
end;
///////////////////////////////////////////////////////////////////////////////
function TImageMaker.GetTransparentImage: TBitmap;
function TImageMaker.GetTransparentImage: TPngObject;
var
x,y: integer;
i,row: integer;
PngObject: TPngObject;
x, y: integer;
i, row: integer;
rowbm, rowpng: PByteArray;
begin
if assigned(FTransparentImage) then FTransparentImage.Free;
FTransparentImage := TBitmap.Create;
FTransparentImage.Width := Fcp.Width;
FTransparentImage.Height := Fcp.Height;
FTransparentImage.Canvas.Brush.Color := $CCCCCC;
FTransparentImage.Canvas.FillRect(Rect(0, 0, Fcp.Width, Fcp.Height));
FTransparentImage.Canvas.Brush.Color := $FFFFFF;
for x := 0 to ((Fcp.Width - 1) div 8) do begin
for y := 0 to ((Fcp.Height - 1) div 8) do begin
if odd(x + y) then
FTransparentImage.Canvas.FillRect(Rect(x * 8, y * 8, x * 8 + 8, y * 8 + 8));
end;
end;
PngObject := TPngObject.Create;
PngObject.Assign(FBitmap);
Result := TPngObject.Create;
Result.Assign(FBitmap);
if fcp.Transparency then begin
PngObject.CreateAlpha;
Result.CreateAlpha;
for i:= 0 to FAlphaBitmap.Height - 1 do begin
rowbm := PByteArray(FAlphaBitmap.scanline[i]);
rowpng := PByteArray(PngObject.AlphaScanline[i]);
rowpng := PByteArray(Result.AlphaScanline[i]);
for row := 0 to FAlphaBitmap.Width - 1 do begin
rowpng[row] := rowbm[row];
end;
end;
end;
PngObject.Draw(FTransparentImage.Canvas, FTransparentImage.Canvas.ClipRect);
PngObject.Free;
Result := FTransparentImage;
end;
///////////////////////////////////////////////////////////////////////////////

View File

@ -232,16 +232,25 @@ object MainForm: TMainForm
ImageIndex = 13
OnClick = mnuOptionsClick
end
object ToolButton6: TToolButton
object tbShowAlpha: TToolButton
Left = 448
Top = 0
Hint = 'Show transparency'
Caption = 'tbShowAlpha'
ImageIndex = 37
Style = tbsCheck
OnClick = tbShowAlphaClick
end
object ToolButton6: TToolButton
Left = 471
Top = 0
Width = 8
Caption = 'ToolButton6'
ImageIndex = 42
Style = tbsSeparator
end
object tbzoomwindow: TToolButton
Left = 456
Left = 479
Top = 0
Hint = 'Zoom to rectangle'
Caption = 'tbzoomwindow'
@ -251,7 +260,7 @@ object MainForm: TMainForm
OnClick = tbzoomwindowClick
end
object tbzoomoutwindow: TToolButton
Left = 479
Left = 502
Top = 0
Hint = 'Zoom out using rectangle'
Caption = 'tbzoomoutwindow'
@ -261,7 +270,7 @@ object MainForm: TMainForm
OnClick = tbzoomoutwindowClick
end
object tbDrag: TToolButton
Left = 502
Left = 525
Top = 0
Hint = 'Translate image'
Caption = 'tbDrag'
@ -272,7 +281,7 @@ object MainForm: TMainForm
OnClick = tbDragClick
end
object tbRotate: TToolButton
Left = 525
Left = 548
Top = 0
Hint = 'Rotate'
Caption = 'tbRotate'
@ -309,7 +318,7 @@ object MainForm: TMainForm
Align = alClient
BevelInner = bvLowered
BevelOuter = bvNone
Color = clBlack
Color = clAppWorkSpace
TabOrder = 2
OnResize = BackPanelResize
object Image: TImage
@ -320,7 +329,6 @@ object MainForm: TMainForm
Align = alClient
AutoSize = True
PopupMenu = DisplayPopup
Stretch = True
OnDblClick = ImageDblClick
OnMouseDown = ImageMouseDown
OnMouseMove = ImageMouseMove
@ -347,7 +355,7 @@ object MainForm: TMainForm
Left = 8
Top = 56
Bitmap = {
494C010135003600040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C010135003600040010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600
000000000000360000002800000040000000E0000000010020000000000000E0
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000292B2F00000000002F3236000000
@ -661,7 +669,7 @@ object MainForm: TMainForm
2400FFEBE000FFE4D20000000000FFE3D200FFD6BE00FFD4BB00FFD6BE00FFDA
C400FFDECA00FFE1CF00000000000000000010408F000F1F60003F7FB0003F70
B0002060A0003070AF001F509F00205F9F0010408F004F8FBF001F509F002F60
A0003F70AF000000000010206F0000000000000000000000000000000000FD9C
A0003F70AF000F103F0010206F0000000000000000000000000000000000FD9C
6900F98D5300F7854600F1824500EA834600E7834800F0854900FF8B4A00FF94
5000FFB37D0000000000000000000000000014131200251926002A2B2B004B44
440097899500B49CB500B7A0B5006E61680086748C00A8B6D9005A5F7D001008
@ -676,8 +684,8 @@ object MainForm: TMainForm
050000000000000000000000000014131200A8604200FFEBE000FFE4D200733C
2400FFE3D200FFD6BE0000000000FFDAC500FFCAAB00FFC7A500FFC7A5000000
00000000000000000000000000000000000010408F0060A0CF004F8FBF003F70
B00000000000103F800000000000000F20000F1F5F00104F900060A0CF008FBF
DF00102F70000000000010206F0000000000000000000000000000000000EBA5
B0003070AF00103F80000F1F5F00000F20000F1F5F00104F900060A0CF008FBF
DF00102F70000F103F0010206F0000000000000000000000000000000000EBA5
7C00E8A07600E79F7300E69D7300DF834D00DD7D4300DD733300E8733200FF9C
680000000000000000000000000000000000141312001610120094818B00C7B2
C6009C89920084718200776F7F005B4D5E0043304100493B5200505169001216
@ -685,7 +693,7 @@ object MainForm: TMainForm
2400FFDECB00FFD0B50000000000FFDAC400FFCBAC00FFC6A500FFC6A5000000
0000F5A7790000000000000000000000000010408F000F1F5F003F7FB0003F70
AF001F509F0010408F002F60A00010307F00609FCF003F70B0005F9FC0004F80
BF000F1050000F103F0010206F00000000000000000000000000000000000000
BF000F1050000F10500010206F00000000000000000000000000000000000000
000000000000000000000000000000000000DD7D4500E0713200F3915B000000
00000000000000000000000000000000000014131200030804007B7E8100E9D9
E400BBA3B000AA95A70073616E0022252A000C0A0E0024161F002B303B001313
@ -879,97 +887,97 @@ object MainForm: TMainForm
E000F9E9E000F9EBE200F9ECE600F9EDE900F5ECE70000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000F0CAB400F4D5
C300C1AB9F00BEB2AB00FFFBF900FFFFFF00B5B5B500B5B5B500FFFFFF00FFFF
FF00B5B5B500B5B5B50000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00A0A0A000A0A0A000A0A0A000A0A0
A000A0A0A000A0A0A00000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000FFF0E700FFEA
DD00FFE9DC00FFEBDF00FFEDE300FFEFE500FDEFE70000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000EAB69700EFC2
A600C8A48F00C6AFA000FEF0E800FFF9F600B7B6B600B5B5B500FFFFFF00FFFF
FF00B5B5B500B5B5B500000000000000000000000000000000007B7B7B00FFFF
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00A0A0A000A0A0A000A0A0A000A0A0
A000A0A0A000A0A0A000000000000000000000000000000000007B7B7B00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF0000000000000000000000000000000000FEEBE000FFE4
D200FFE2D100FFE4D400FFE6D700FFE8DA00FCE6DA0000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000CE8D6600CE92
6E00F1BFA200F8D4BF00CEB6A800C9BBB300FFFAF600FFFEFD00B5B5B500B5B5
B500FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00A0A0A000A0A0A000A0A0A000A0A0A000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00A0A0A000A0A0A000000000000000000000000000000000007B7B7B000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000FFFFFF0000000000000000000000000000000000FEE7D900FFDD
C800FFDBC600FFDDC900FFDFCC00FFE0D000FCDFD00000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000D4855500D48A
5D00EDAE8900F6C6AA00D9B7A200D3BFB300FFF5EF00FFFCFB00BCBEC000B4B7
B900FFFFFF00FEFFFF00000000000000000000000000000000007B7B7B000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00A0A0A000A0A0A000A0A0A000A0A0A000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00A0A0A000A0A0A000000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000FFE4D300FFD6
BE00FFD4BB00FFD6BE00FFDEC700FFE3CE00FCE2D00000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000D97D4500E089
5200DD906300E0A48100FED1B700FFE2D200D8CAC100D1CDCA00F6FBFE00EBF6
FE00ABB5BC00B1B4B700000000000000000000000000000000007B7B7B000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00A0A0A000A0A0A000A0A0A000A0A0A000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00A0A0A000A0A0A000000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FFFFFF00FF000000FF000000FFFFFF00FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000FFDFCD00FFD0
B500FFCDAF00FFD0B400F2CCB400EFD3C200ECD5C70000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000D97D4500DD7C
4200E4895400EAA17600FDC6A600FFDCC700E3D0C400DCD6D300F2F9FE00DDF0
FD009EB5C6009EB1BF00000000000000000000000000000000007B7B7B000000
0000000000000000000000000000000000000000000000000000FFFFFF00FFFF
FF00A0A0A000A0A0A000A0A0A000A0A0A000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00A0A0A000A0A0A000000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FF000000FFFFFF00FFFFFF00FF000000FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000FFDBC700FFCA
AB00FFC7A500FFD4B20000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000D97D4500DD7D
4200E6885100F19F6E00F8B89100F4C9B000FFE7DA00FFF8F300CFD9DF00AAC4
D600BCE1FA00BDE0FA00000000000000000000000000000000007B7B7B000000
0000000000000000000000000000000000000000000000000000A0A0A000A0A0
A000FFFFFF00FFFFFF00FFFFFF00FFFFFF00A0A0A000A0A0A000A0A0A000A0A0
A000FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FF000000FFFFFF00FFFFFF00FF000000FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000FFDAC500FFCB
AC00FFC6A500FFD3B20000000000F5A779000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000D97D4500DD7D
4200E5885000F19F6E00FDB78F00FFCDAF00FFE3D300FFF6F000D5E2EA00A7C9
E000A5D6F8009FD2F700000000000000000000000000000000007B7B7B000000
0000000000000000000000000000000000000000000000000000A0A0A000A0A0
A000FFFFFF00FFFFFF00FFFFFF00FFFFFF00A0A0A000A0A0A000A0A0A000A0A0
A000FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FF000000FFFFFF00FFFFFF00FF000000FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000FDE2D300FEDC
C600FED9C300FEE3CD003D2F2800000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DA7D4600DD7C
4100E6895200F19E6E00FDB88F00FFCDAF00FFE0CE00FDF2EC00E5F4FD00B3DD
F90078B6E10064A7DA00000000000000000000000000000000007B7B7B000000
0000000000000000000000000000000000000000000000000000A0A0A000A0A0
A000FFFFFF00FFFFFF00FFFFFF00FFFFFF00A0A0A000A0A0A000A0A0A000A0A0
A000FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FFFFFF00FF000000FF000000FFFFFF00FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DA7F4800DE7F
4600E68C5600F0A17300FCBA9300FFCEB100FFE1D000FFF4ED00E2F2FD00A8D7
F8006EB8EA0055A6E200000000000000000000000000000000007B7B7B000000
0000000000000000000000000000000000000000000000000000A0A0A000A0A0
A000FFFFFF00FFFFFF00FFFFFF00FFFFFF00A0A0A000A0A0A000A0A0A000A0A0
A000FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B000000
0000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF0000000000FFFFFF0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DB834E00E087
5200E8956300F3A97E00FDC09C00FFD2B800FFE4D400FFF5EF00E4F3FD00AAD9
F9006FBEF40059B1F200000000000000000000000000000000007B7B7B000000
0000000000000000000000000000000000000000000000000000A0A0A000A0A0
A000A0A0A000A0A0A000A0A0A000A0A0A000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000FFFFFF0000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000707A81002D3134002D31
34000B0C0D002D3134002D3134004F565B000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DD8A5800E395
6500ECA57A00F5B69200FDCAAB00FFD9C300FFE8DB00FFF7F200E8F5FD00B7DF
FA0085C8F70063B6F200000000000000000000000000000000007B7B7B007B7B
0000000000000000000000000000000000000000000000000000A0A0A000A0A0
A000A0A0A000A0A0A000A0A0A000A0A0A000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00000000000000000000000000000000007B7B7B007B7B
7B007B7B7B007B7B7B007B7B7B007B7B7B007B7B7B007B7B7B007B7B7B007B7B
7B007B7B7B007B7B7B0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -2153,7 +2161,7 @@ object MainForm: TMainForm
EDB6C00FC00F8000CDB2C00FC00F8000D9B5C00FC00F800FE5B7E01FE01F800F
FD8FF03FF03F800FFE7FFFFFFFFF800FFFFF0000FFFFFFFFFFFF0000FC010001
FE7F0000FC010001FE3F0000E0010001FE1F0000E0010001C00F000000010001
C007000000010001C003000000010001C003000000010805C007000000030001
C007000000010001C003000000010001C003000000010001C007000000030001
C00F000000070001FE1F0000000F0001FE3F0000003F0001FE7F0000007F0001
FFFF000001FF0001FFFF000003FF0001FFE7FFFFFFFFFFFFFFE7FFFF803FFFFF
FFE7F81F803FE7FFE000F3CF803FE1FFE000EFEF803FE07FE3E7CFFF800FE01F
@ -2199,8 +2207,7 @@ object MainForm: TMainForm
C003000F80018000C003000780018000C003000380018000C003000180018000
C003000180018000C003001F80018000C003001F80018001C003001F80018001
C0038FF180018001C007FFF980018001C00FFF7580018001C01FFF8F80018001
C03FFFFF80018001FFFFFFFFFFFFFFFF00000000000000000000000000000000
000000000000}
C03FFFFF80018001FFFFFFFFFFFFFFFF}
end
object SmallImages: TImageList
Left = 40

View File

@ -28,7 +28,7 @@ uses
ToolWin, StdCtrls, Classes, Messages, ExtCtrls, ImgList, controlpoint,
Jpeg, SyncObjs, SysUtils, ClipBrd, Graphics, Math, Global,
Registry, RenderThread, Cmap, ExtDlgs, AppEvnts, ShellAPI,
LibXmlParser, LibXmlComps, Xform, XFormMan;
LibXmlParser, LibXmlComps, Xform, XFormMan, PngImage;
const
PixelCountMax = 32768;
@ -37,7 +37,7 @@ const
RS_XO = 2;
RS_VO = 3;
AppVersionString = 'Apophysis 2.05 pre-release 11';
AppVersionString = 'Apophysis 2.05 pre-release 12';
type
TMouseMoveState = (msUsual, msZoomWindow, msZoomOutWindow, msZoomWindowMove, msZoomOutWindowMove, msDrag, msDragMove, msRotate, msRotateMove);
@ -174,6 +174,7 @@ type
ToolButton6: TToolButton;
tbQualityBox: TComboBox;
View1: TMenuItem;
tbShowAlpha: TToolButton;
procedure tbzoomoutwindowClick(Sender: TObject);
procedure mnuimageClick(Sender: TObject);
procedure mnuExitClick(Sender: TObject);
@ -268,15 +269,20 @@ type
procedure tbQualityBoxKeyPress(Sender: TObject; var Key: Char);
procedure tbQualityBoxSet(Sender: TObject);
procedure ImageDblClick(Sender: TObject);
procedure tbShowAlphaClick(Sender: TObject);
private
Renderer: TRenderThread;
FMouseMoveState: TMouseMoveState;
FSelectRect: TRect;
FRotateAngle: double;
FClickAngle: double; // --Z--
FViewBMP: Graphics.TBitmap;
FClickAngle: double;
FViewImage: TPngObject;
FViewPos: TPoint;
FViewScale: double;
procedure DrawImageView;
procedure DrawZoomWindow(ARect: TRect);
procedure DrawRotatelines(Angle: double);
@ -1679,17 +1685,18 @@ end;
{ ****************************** Display ************************************ }
procedure TMainForm.HandleThreadCompletion(var Message: TMessage);
var
bm: TBitmap;
begin
if Assigned(Renderer) then begin
bm := TBitmap.Create;
bm.assign(Renderer.GetImage);
Image.Picture.Graphic := bm;
Renderer.Free;
Renderer := nil;
bm.Free;
end;
if not Assigned(Renderer) then exit;
if assigned(FViewImage) then FViewImage.Free;
FViewPos.X := 0;
FViewPos.Y := 0;
FViewScale := 1;
FViewImage := Renderer.GetTransparentImage;
DrawImageView;
Renderer.Free;
Renderer := nil;
end;
procedure TMainForm.HandleThreadTermination(var Message: TMessage);
@ -1729,9 +1736,7 @@ begin
MainCp.sample_density := defSampleDensity;
Maincp.spatial_oversample := defOversample;
Maincp.spatial_filter_radius := defFilterRadius;
MainCP.Transparency := (PNGTransparency <> 0) and ShowTransparency;
MainCP.Transparency := true; // always generate transparency data
StartTime := Now;
Remainder := 1;
try
@ -1964,6 +1969,7 @@ begin
StopThread;
RedrawTimer.Enabled := True;
tbQualityBox.Text := FloatToStr(defSampleDensity);
tbShowAlpha.Down := ShowTransparency;
UpdateWindows;
end;
@ -2369,6 +2375,7 @@ begin
FillVariantMenu;
tbQualityBox.Text := FloatToStr(defSampleDensity);
tbShowAlpha.Down := ShowTransparency;
end;
procedure TMainForm.FormShow(Sender: TObject);
@ -2514,7 +2521,8 @@ begin
if assigned(Renderer) then Renderer.Terminate;
if assigned(Renderer) then Renderer.WaitFor;
if assigned(Renderer) then Renderer.Free;
maincp.free;
if assigned(FViewImage) then FViewImage.Free;
MainCP.free;
ParseCp.free;
Favorites.Free;
end;
@ -2531,6 +2539,7 @@ begin
StopThread;
if CanDrawOnResize then
reDrawTimer.Enabled := True;
DrawImageView;
end;
procedure TMainForm.LoadXMLFlame(filename, name: string);
@ -4017,6 +4026,8 @@ begin
end;
msDrag:
begin
if not assigned(FViewImage) then exit;
{
if not assigned(FViewBMP) then
FViewBMP := TBitmap.Create;
FViewBMP.Width := ClientWidth + 100;
@ -4040,7 +4051,7 @@ begin
DestRect.BottomRight.Y := DestRect.BottomRight.Y + 50;
FViewBMP.Canvas.CopyRect(DestRect, Image.Canvas, SourceRect);
}
FSelectRect.TopLeft := Point(x, y);
FSelectRect.BottomRight := Point(x, y);
FMouseMoveState := msDragMove;
@ -4058,11 +4069,10 @@ begin
end;
///////////////////////////////////////////////////////////////////////////////
procedure TMainForm.ImageMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure TMainForm.ImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
DestRect, SrcRect: TRect;
FOffs : TPoint;
DestRect: TRect;
dx, dy: integer;
begin
case FMouseMoveState of
msZoomWindowMove,
@ -4074,18 +4084,14 @@ begin
end;
msDragMove:
begin
FOffs.X := x - FSelectRect.TopLeft.x;
FOffs.Y := y - FSelectRect.TopLeft.Y;
assert(assigned(FviewImage));
assert(FViewScale <> 0);
FViewPos.X := FViewPos.X + round( (x - FSelectRect.Right) / FViewScale);
FViewPos.Y := FViewPos.Y + round( (y - FSelectRect.Bottom) / FViewScale);
FSelectRect.BottomRight := Point(x, y);
DestRect := ClientRect;
SrcRect.Left := -FOffs.X + 50;
SrcRect.Right := ClientRect.Right - FOffs.X + 50;;
SrcRect.Top := - FOffs.Y + 50;
SrcRect.Bottom := ClientRect.Bottom - FOffs.Y + 50;
Image.Canvas.CopyRect(DestRect, FViewBMP.Canvas, SrcRect);
DrawImageView;
end;
msRotateMove:
begin
@ -4149,9 +4155,6 @@ begin
end;
msDragMove:
begin
FViewBMP.Free;
FViewBMP := nil;
FSelectRect.BottomRight := Point(x, y);
FMouseMoveState := msDrag;
@ -4185,6 +4188,48 @@ begin
end;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TMainForm.DrawImageView;
var
i, j: integer;
bm: TBitmap;
r: TRect;
begin
bm := TBitmap.Create;
bm.Width := Image.Width;
bm.Height := Image.Height;
with bm.Canvas do begin
if ShowTransparency then begin
Brush.Color := $F0F0F0;
FillRect(Rect(0, 0, bm.Width, bm.Height));
Brush.Color := $C0C0C0;
for i := 0 to ((bm.Width - 1) shr 3) do begin
for j := 0 to ((bm.Height - 1) shr 3) do begin
if odd(i + j) then
FillRect(Rect(i shl 3, j shl 3, (i+1) shl 3, (j+1) shl 3));
end;
end;
end
else begin
Brush.Color := MainCP.background[0] or (MainCP.background[1] shl 8) or (MainCP.background[2] shl 16);
FillRect(Rect(0, 0, bm.Width, bm.Height));
end;
end;
if assigned(FViewImage) then begin
FViewScale := Image.Width / FViewImage.Width;
r.Left := round(FViewScale * FViewPos.X);
r.Right := round(FViewScale * (FViewPos.X + FViewImage.Width));
r.Top := Image.Height div 2 + round(FViewScale * (FViewPos.Y - FViewImage.Height/2));
r.Bottom := Image.Height div 2 + round(FViewScale * (FViewPos.Y + FViewImage.Height/2));
FViewImage.Draw(bm.Canvas, r);
end;
Image.Picture.Graphic := bm;
Image.Refresh;
bm.Free;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TMainForm.DrawRotateLines(Angle: double);
var
@ -4364,5 +4409,14 @@ end;
{$ENDIF}
///////////////////////////////////////////////////////////////////////////////
procedure TMainForm.tbShowAlphaClick(Sender: TObject);
var
DestRect: TRect;
bm: TBitmap;
begin
ShowTransparency := tbShowAlpha.Down;
DrawImageView;
end;
end.

View File

@ -23,7 +23,7 @@ interface
uses
Windows, Graphics, Classes,
Controlpoint, RenderTypes, ImageMaker;
Controlpoint, RenderTypes, ImageMaker, PngImage;
///////////////////////////////////////////////////////////////////////////////
//
@ -102,6 +102,7 @@ type
procedure Render; virtual;
function GetImage: TBitmap; virtual;
function GetTransparentImage: TPngObject;
procedure UpdateImage(CP: TControlPoint);
procedure SaveImage(const FileName: String);
@ -251,13 +252,25 @@ end;
///////////////////////////////////////////////////////////////////////////////
function TBaseRenderer.GetImage: TBitmap;
begin
if FStop <> 0 then begin
if FStop > 0 then begin
assert(false);
FImageMaker.OnProgress := OnProgress;
FImageMaker.CreateImage;
end;
Result := FImageMaker.GetImage;
end;
///////////////////////////////////////////////////////////////////////////////
function TBaseRenderer.GetTransparentImage: TPngObject;
begin
if FStop > 0 then begin
assert(false);
FImageMaker.OnProgress := OnProgress;
FImageMaker.CreateImage;
end;
Result := FImageMaker.GetTransparentImage;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TBaseRenderer.UpdateImage(CP: TControlPoint);
begin
@ -278,7 +291,7 @@ end;
///////////////////////////////////////////////////////////////////////////////
procedure TBaseRenderer.SaveImage(const FileName: String);
begin
if FStop <> 0 then begin
if FStop > 0 then begin
if Assigned(strOutput) then
strOutput.Add(TimeToStr(Now) + Format(' : Creating image with quality = %f', [fcp.actual_density]));
FImageMaker.OnProgress := OnProgress;
@ -476,7 +489,7 @@ begin
SetPixels;
RenderTime := Now - RenderTime;
if FStop >= 0 then begin
if FStop <= 0 then begin
if Assigned(strOutput) then begin
if fcp.sample_density = fcp.actual_density then
strOutput.Add(TimeToStr(Now) + ' : Creating image')

View File

@ -30,7 +30,6 @@ type
protected
Buckets: TBucket32Array;
// ColorMap: TColorMapArray;
function GetBits: integer; override;
function GetBucketsPtr: pointer; override;
@ -100,8 +99,6 @@ procedure TRenderer32MT.AddPointsToBuckets(const points: TPointsArray);
var
i: integer;
px, py: double;
// R: double;
// V1, v2, v3: integer;
Bucket: PBucket32;
MapColor: PColorMapColor;
begin

View File

@ -24,7 +24,7 @@ interface
uses
Classes, Windows, Messages, Graphics,
ControlPoint, Render,
Global, RenderTypes,
Global, RenderTypes, PngImage,
Render64, Render64MT,
Render48, Render48MT,
Render32, Render32MT,
@ -65,6 +65,7 @@ type
procedure SetCP(CP: TControlPoint);
function GetImage: TBitmap;
function GetTransparentImage: TPngObject;
procedure SaveImage(const FileName: String);
procedure Execute; override;
@ -126,6 +127,14 @@ begin
Result := FRenderer.GetImage;
end;
///////////////////////////////////////////////////////////////////////////////
function TRenderThread.GetTransparentImage: TPngObject;
begin
Result := nil;
if assigned(FRenderer) then
Result := FRenderer.GetTransparentImage;
end;
///////////////////////////////////////////////////////////////////////////////
procedure TRenderThread.SetCP(CP: TControlPoint);
begin

View File

@ -307,7 +307,8 @@ function TVariationRadialBlur.ResetVariable(const Name: string): boolean;
begin
Result := False;
if Name = var_a_name then begin
angle := 0;
if angle <> 0 then angle := 0
else if angle = 0 then angle := 1;
Result := True;
end;
end;