diff options
author | marco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-02-04 16:13:51 +0000 |
---|---|---|
committer | marco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-02-04 16:13:51 +0000 |
commit | 90ead351fcc8730e92304c8b0dba07c87408ed79 (patch) | |
tree | cf1ce5f11dbe9c42a165cbbf7b188785ceb5f89c | |
parent | ed87e795db2412d0c100e419b42898dae21d32fe (diff) | |
download | fpc-90ead351fcc8730e92304c8b0dba07c87408ed79.tar.gz |
--- Merging r48428 into '.':
U packages/pasjpeg/examples/example.pas
--- Recording mergeinfo for merge of r48428 into '.':
U .
--- Merging r48431 into '.':
A packages/pasjpeg/examples/demo.lpi
--- Recording mergeinfo for merge of r48431 into '.':
G .
--- Merging r48463 into '.':
U packages/graph/src/inc/graph.tex
--- Recording mergeinfo for merge of r48463 into '.':
G .
--- Merging r48115 into '.':
U packages/fv/src/views.pas
--- Recording mergeinfo for merge of r48115 into '.':
G .
# revisions: 48428,48431,48463,48115
r48428 | florian | 2021-01-25 22:29:14 +0100 (Mon, 25 Jan 2021) | 1 line
Changed paths:
M /trunk/packages/pasjpeg/examples/example.pas
* fix demo example for delphi_stream being defined
r48431 | florian | 2021-01-26 23:00:33 +0100 (Tue, 26 Jan 2021) | 1 line
Changed paths:
A /trunk/packages/pasjpeg/examples/demo.lpi
+ lazarus project for demo
r48463 | nickysn | 2021-01-31 12:08:21 +0100 (Sun, 31 Jan 2021) | 1 line
Changed paths:
M /trunk/packages/graph/src/inc/graph.tex
* set eol-style=native and mime-type=text/plain to graph.tex
r48115 | florian | 2021-01-08 17:33:05 +0100 (Fri, 08 Jan 2021) | 1 line
Changed paths:
M /trunk/packages/fv/src/views.pas
* avoid div by zero in TView.CalcBounds.GrowI, resolves #30922
git-svn-id: https://svn.freepascal.org/svn/fpc/branches/fixes_3_2@48511 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r-- | packages/fv/src/views.pas | 3 | ||||
-rw-r--r-- | packages/pasjpeg/examples/demo.lpi | 53 | ||||
-rw-r--r-- | packages/pasjpeg/examples/example.pas | 40 |
3 files changed, 93 insertions, 3 deletions
diff --git a/packages/fv/src/views.pas b/packages/fv/src/views.pas index 747dbd2a2e..01665f71a0 100644 --- a/packages/fv/src/views.pas +++ b/packages/fv/src/views.pas @@ -1899,7 +1899,8 @@ VAR S, D: Sw_Integer; Min, Max: TPoint; PROCEDURE GrowI (Var I: Sw_Integer); BEGIN If (GrowMode AND gfGrowRel = 0) Then Inc(I, D) - Else I := (I * S + (S - D) SHR 1) DIV (S - D); { Calc grow value } + Else If S = D then I := 1 + Else I := (I * S + (S - D) SHR 1) DIV (S - D); { Calc grow value } END; BEGIN diff --git a/packages/pasjpeg/examples/demo.lpi b/packages/pasjpeg/examples/demo.lpi new file mode 100644 index 0000000000..99fac0cd7f --- /dev/null +++ b/packages/pasjpeg/examples/demo.lpi @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <ProjectOptions> + <Version Value="12"/> + <General> + <Flags> + <MainUnitHasCreateFormStatements Value="False"/> + <MainUnitHasTitleStatement Value="False"/> + <MainUnitHasScaledStatement Value="False"/> + <UseDefaultCompilerOptions Value="True"/> + </Flags> + <SessionStorage Value="InProjectDir"/> + <Title Value="demo"/> + <UseAppBundle Value="False"/> + <ResourceType Value="res"/> + </General> + <BuildModes> + <Item Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + </RunParams> + <Units> + <Unit> + <Filename Value="demo.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="Demo"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <Target> + <Filename Value="demo"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <OtherUnitFiles Value="../src"/> + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + </CompilerOptions> + <Debugging> + <Exceptions> + <Item> + <Name Value="ECompilerAbort"/> + </Item> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/packages/pasjpeg/examples/example.pas b/packages/pasjpeg/examples/example.pas index 5362912c8c..a4f052883b 100644 --- a/packages/pasjpeg/examples/example.pas +++ b/packages/pasjpeg/examples/example.pas @@ -1,3 +1,8 @@ +{$IFDEF FPC} +{$MODE DELPHI} +{$GOTO ON} +{$DEFINE DELPHI_STREAM} +{$ENDIF} Unit example; { This file illustrates how to use the IJG code as a subroutine library @@ -37,6 +42,10 @@ function read_JPEG_file (filename : string) : boolean; implementation +{$ifdef delphi_stream} + uses + Classes; +{$endif delphi_stream} { <setjmp.h> is used for the optional error recovery mechanism shown in the second part of the example. } @@ -93,7 +102,11 @@ var jerr : jpeg_error_mgr; { More stuff } +{$ifdef delphi_stream} + outfile : TFileStream; +{$else delphi_stream} outfile : FILE; { target file } +{$endif delphi_stream} row_pointer : array[0..0] of JSAMPROW ; { pointer to JSAMPLE row[s] } row_stride : int; { physical row width in image buffer } begin @@ -117,7 +130,9 @@ begin stdio stream. You can also write your own code to do something else. VERY IMPORTANT: use "b" option to fopen() if you are on a machine that requires it in order to write binary files. } - +{$ifdef delphi_stream} + outfile := TFileStream.Create(filename, fmCreate); +{$else delphi_stream} Assign(outfile, filename); {$push}{$I-} ReWrite(outfile, 1); @@ -127,6 +142,7 @@ begin WriteLn(output, 'can''t open ', filename); Halt(1); end; +{$endif delphi_stream} jpeg_stdio_dest(@cinfo, @outfile); { Step 3: set parameters for compression } @@ -179,7 +195,11 @@ begin jpeg_finish_compress(@cinfo); { After finish_compress, we can close the output file. } +{$ifdef delphi_stream} + outfile.Free; +{$else delphi_stream} system.close(outfile); +{$endif delphi_stream} { Step 7: release JPEG compression object } @@ -321,7 +341,11 @@ var jerr : my_error_mgr; { More stuff } - infile : FILE; { source file } +{$ifdef delphi_stream} + infile : TFileStream; +{$else delphi_stream} + infile : FILE; { target file } +{$endif delphi_stream} buffer : JSAMPARRAY; { Output row buffer } row_stride : int; { physical row width in output buffer } begin @@ -331,6 +355,9 @@ begin VERY IMPORTANT: use "b" option to fopen() if you are on a machine that requires it in order to read binary files. } +{$ifdef delphi_stream} + infile := TFileStream.Create(filename, fmOpenRead); +{$else delphi_stream} Assign(infile, filename); {$push}{$I-} Reset(infile, 1); @@ -341,6 +368,7 @@ begin read_JPEG_file := FALSE; exit; end; +{$endif delphi_stream} { Step 1: allocate and initialize JPEG decompression object } @@ -356,7 +384,11 @@ begin { Nomssi: if we get here, we are in trouble, because e.g. cinfo.mem is not guaranted to be NIL } jpeg_destroy_decompress(@cinfo); +{$ifdef delphi_stream} + infile.Free; +{$else delphi_stream} system.close(infile); +{$endif delphi_stream} read_JPEG_file := FALSE; exit; end; @@ -440,7 +472,11 @@ begin Here we postpone it until after no more JPEG errors are possible, so as to simplify the setjmp error logic above. (Actually, I don't think that jpeg_destroy can do an error exit, but why assume anything...) } +{$ifdef delphi_stream} + infile.Free; +{$else delphi_stream} system.close(infile); +{$endif delphi_stream} { At this point you may want to check to see whether any corrupt-data warnings occurred (test whether jerr.pub.num_warnings is nonzero). } |