Subversion Repositories forest

Compare Revisions

No changes between revisions

Regard whitespace Rev 1 → Rev 2

/trunk/dll_resize/Old-Resize-Code.dba
0,0 → 1,26
 
#constant DLL_DBProImageDebug 1
#constant FN_DLL_DBProImageDebug "DBProImageDebug.dll"
 
function resizeImage(image as dword, width as dword, height as dword)
rem https://forum.thegamecreators.com/thread/191558#msg2284289 , modified
rem ATTENTION! Will crash when you try to increase the size (resize small picture into large picture)!
 
if DLL EXIST(DLL_DBProImageDebug) = 0
load dll FN_DLL_DBProImageDebug, DLL_DBProImageDebug
ENDIF
 
call dll DLL_DBProImageDebug, "?Stretch@@YAXHHH@Z", image, width, height // This function won't reset the size
pWidth = make memory(4)
pHeight = make memory(4)
pDepth = make memory(4)
ppData = make memory(4)
pSize = make memory(4)
call dll DLL_DBProImageDebug, "?GetImageData@@YAXHPAK00PAPAD0_N@Z", image, pWidth, pHeight, pDepth, ppData, pSize, 1
call dll DLL_DBProImageDebug, "?SetImageData@@YAXHKKKPADK@Z", image, width, height, *pDepth, *ppData, *pSize
delete memory pWidth
delete memory pHeight
delete memory pDepth
delete memory ppData
delete memory pSize
endfunction
/trunk/dll_resize/Resize32-Usage-Example.dba
0,0 → 1,28
 
#constant DLL_Resize 12
#constant MEM_ResizeSrc 13
#constant MEM_ResizeDest 14
 
#constant DLL_FN_Resize "Resize32.dll"
 
 
function resizeImage(image as dword, width as dword, height as dword)
if DLL EXIST(DLL_Resize) = 0
load dll DLL_FN_Resize, DLL_Resize
endif
make memblock from image MEM_ResizeSrc, image
size = call dll(DLL_Resize, "DestSize", get memblock ptr(MEM_ResizeSrc), width, height)
make memblock MEM_ResizeDest, size
 
call dll DLL_Resize, "Resize", get memblock ptr(MEM_ResizeSrc), get memblock ptr(MEM_ResizeDest), width, height
make image from memblock image, MEM_ResizeDest
delete memblock MEM_ResizeSrc
delete memblock MEM_ResizeDest
REM delete dll DLL_Resize
endfunction
/trunk/dll_resize/Resize32.bdsproj
0,0 → 1,175
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject>
<PersonalityInfo>
<Option>
<Option Name="Personality">Delphi.Personality</Option>
<Option Name="ProjectType"></Option>
<Option Name="Version">1.0</Option>
<Option Name="GUID">{1E3FA68A-E26C-471B-9D2F-4F6C078E6FAA}</Option>
</Option>
</PersonalityInfo>
<Delphi.Personality>
<Source>
<Source Name="MainSource">Resize32.dpr</Source>
</Source>
<FileVersion>
<FileVersion Name="Version">7.0</FileVersion>
</FileVersion>
<Compiler>
<Compiler Name="A">8</Compiler>
<Compiler Name="B">0</Compiler>
<Compiler Name="C">1</Compiler>
<Compiler Name="D">1</Compiler>
<Compiler Name="E">0</Compiler>
<Compiler Name="F">0</Compiler>
<Compiler Name="G">1</Compiler>
<Compiler Name="H">1</Compiler>
<Compiler Name="I">1</Compiler>
<Compiler Name="J">0</Compiler>
<Compiler Name="K">0</Compiler>
<Compiler Name="L">1</Compiler>
<Compiler Name="M">0</Compiler>
<Compiler Name="N">1</Compiler>
<Compiler Name="O">1</Compiler>
<Compiler Name="P">1</Compiler>
<Compiler Name="Q">0</Compiler>
<Compiler Name="R">0</Compiler>
<Compiler Name="S">0</Compiler>
<Compiler Name="T">0</Compiler>
<Compiler Name="U">0</Compiler>
<Compiler Name="V">1</Compiler>
<Compiler Name="W">0</Compiler>
<Compiler Name="X">1</Compiler>
<Compiler Name="Y">1</Compiler>
<Compiler Name="Z">1</Compiler>
<Compiler Name="ShowHints">True</Compiler>
<Compiler Name="ShowWarnings">True</Compiler>
<Compiler Name="UnitAliases">WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;</Compiler>
<Compiler Name="NamespacePrefix"></Compiler>
<Compiler Name="GenerateDocumentation">False</Compiler>
<Compiler Name="DefaultNamespace"></Compiler>
<Compiler Name="SymbolDeprecated">True</Compiler>
<Compiler Name="SymbolLibrary">True</Compiler>
<Compiler Name="SymbolPlatform">True</Compiler>
<Compiler Name="SymbolExperimental">True</Compiler>
<Compiler Name="UnitLibrary">True</Compiler>
<Compiler Name="UnitPlatform">True</Compiler>
<Compiler Name="UnitDeprecated">True</Compiler>
<Compiler Name="UnitExperimental">True</Compiler>
<Compiler Name="HResultCompat">True</Compiler>
<Compiler Name="HidingMember">True</Compiler>
<Compiler Name="HiddenVirtual">True</Compiler>
<Compiler Name="Garbage">True</Compiler>
<Compiler Name="BoundsError">True</Compiler>
<Compiler Name="ZeroNilCompat">True</Compiler>
<Compiler Name="StringConstTruncated">True</Compiler>
<Compiler Name="ForLoopVarVarPar">True</Compiler>
<Compiler Name="TypedConstVarPar">True</Compiler>
<Compiler Name="AsgToTypedConst">True</Compiler>
<Compiler Name="CaseLabelRange">True</Compiler>
<Compiler Name="ForVariable">True</Compiler>
<Compiler Name="ConstructingAbstract">True</Compiler>
<Compiler Name="ComparisonFalse">True</Compiler>
<Compiler Name="ComparisonTrue">True</Compiler>
<Compiler Name="ComparingSignedUnsigned">True</Compiler>
<Compiler Name="CombiningSignedUnsigned">True</Compiler>
<Compiler Name="UnsupportedConstruct">True</Compiler>
<Compiler Name="FileOpen">True</Compiler>
<Compiler Name="FileOpenUnitSrc">True</Compiler>
<Compiler Name="BadGlobalSymbol">True</Compiler>
<Compiler Name="DuplicateConstructorDestructor">True</Compiler>
<Compiler Name="InvalidDirective">True</Compiler>
<Compiler Name="PackageNoLink">True</Compiler>
<Compiler Name="PackageThreadVar">True</Compiler>
<Compiler Name="ImplicitImport">True</Compiler>
<Compiler Name="HPPEMITIgnored">True</Compiler>
<Compiler Name="NoRetVal">True</Compiler>
<Compiler Name="UseBeforeDef">True</Compiler>
<Compiler Name="ForLoopVarUndef">True</Compiler>
<Compiler Name="UnitNameMismatch">True</Compiler>
<Compiler Name="NoCFGFileFound">True</Compiler>
<Compiler Name="ImplicitVariants">True</Compiler>
<Compiler Name="UnicodeToLocale">True</Compiler>
<Compiler Name="LocaleToUnicode">True</Compiler>
<Compiler Name="ImagebaseMultiple">True</Compiler>
<Compiler Name="SuspiciousTypecast">True</Compiler>
<Compiler Name="PrivatePropAccessor">True</Compiler>
<Compiler Name="UnsafeType">False</Compiler>
<Compiler Name="UnsafeCode">False</Compiler>
<Compiler Name="UnsafeCast">False</Compiler>
<Compiler Name="OptionTruncated">True</Compiler>
<Compiler Name="WideCharReduced">True</Compiler>
<Compiler Name="DuplicatesIgnored">True</Compiler>
<Compiler Name="UnitInitSeq">True</Compiler>
<Compiler Name="LocalPInvoke">True</Compiler>
<Compiler Name="MessageDirective">True</Compiler>
<Compiler Name="CodePage"></Compiler>
</Compiler>
<Linker>
<Linker Name="MapFile">0</Linker>
<Linker Name="OutputObjs">0</Linker>
<Linker Name="GenerateHpps">False</Linker>
<Linker Name="ConsoleApp">1</Linker>
<Linker Name="DebugInfo">False</Linker>
<Linker Name="RemoteSymbols">False</Linker>
<Linker Name="GenerateDRC">False</Linker>
<Linker Name="MinStackSize">16384</Linker>
<Linker Name="MaxStackSize">1048576</Linker>
<Linker Name="ImageBase">4194304</Linker>
<Linker Name="ExeDescription"></Linker>
</Linker>
<Directories>
<Directories Name="OutputDir"></Directories>
<Directories Name="UnitOutputDir"></Directories>
<Directories Name="PackageDLLOutputDir"></Directories>
<Directories Name="PackageDCPOutputDir"></Directories>
<Directories Name="SearchPath"></Directories>
<Directories Name="Packages"></Directories>
<Directories Name="Conditionals"></Directories>
<Directories Name="DebugSourceDirs"></Directories>
<Directories Name="UsePackages">False</Directories>
</Directories>
<Parameters>
<Parameters Name="RunParams"></Parameters>
<Parameters Name="HostApplication">Forest.exe</Parameters>
<Parameters Name="Launcher"></Parameters>
<Parameters Name="UseLauncher">False</Parameters>
<Parameters Name="DebugCWD"></Parameters>
<Parameters Name="Debug Symbols Search Path"></Parameters>
<Parameters Name="LoadAllSymbols">True</Parameters>
<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
</Parameters>
<Language>
<Language Name="ActiveLang"></Language>
<Language Name="ProjectLang">$00000000</Language>
<Language Name="RootDir"></Language>
</Language>
<VersionInfo>
<VersionInfo Name="IncludeVerInfo">True</VersionInfo>
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
<VersionInfo Name="Private">False</VersionInfo>
<VersionInfo Name="DLL">True</VersionInfo>
<VersionInfo Name="Locale">1031</VersionInfo>
<VersionInfo Name="CodePage">1252</VersionInfo>
</VersionInfo>
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName">ViaThinkSoft</VersionInfoKeys>
<VersionInfoKeys Name="FileDescription">Resize library for DarkBASIC</VersionInfoKeys>
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName">Resize 24/32</VersionInfoKeys>
<VersionInfoKeys Name="LegalCopyright">(C) 2016 ViaThinkSoft</VersionInfoKeys>
<VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys>
<VersionInfoKeys Name="OriginalFilename">Resize32.dll</VersionInfoKeys>
<VersionInfoKeys Name="ProductName"></VersionInfoKeys>
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="Comments"></VersionInfoKeys>
</VersionInfoKeys>
</Delphi.Personality>
</BorlandProject>
/trunk/dll_resize/Resize32.bdsproj.local
0,0 → 1,2
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject/>
/trunk/dll_resize/Resize32.cfg
0,0 → 1,38
-$A8
-$B-
-$C+
-$D+
-$E-
-$F-
-$G+
-$H+
-$I+
-$J-
-$K-
-$L+
-$M-
-$N+
-$O+
-$P+
-$Q-
-$R-
-$S-
-$T-
-$U-
-$V+
-$W-
-$X+
-$YD
-$Z1
-cg
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-H+
-W+
-M
-$M16384,1048576
-K$00400000
-LE"C:\Users\DELL User\Documents\Borland Studio-Projekte\Bpl"
-LN"C:\Users\DELL User\Documents\Borland Studio-Projekte\Bpl"
-w-UNSAFE_TYPE
-w-UNSAFE_CODE
-w-UNSAFE_CAST
/trunk/dll_resize/Resize32.dll
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/dll_resize/Resize32.dpr
0,0 → 1,256
library Resize32;
 
{$R *.res}
 
type
TImgMemBlockHeader = packed record
width: cardinal;
height: cardinal;
colordepth: cardinal;
end;
PImgMemBlockHeader = ^TImgMemBlockHeader;
 
function _Resize24(srcMemblock, dstMemblock: PImgMemBlockHeader; newWidth, newHeight: Cardinal): integer;
// --- Based on http://www.davdata.nl/math/bmresize.html ---
type
TBGRATriple = packed record
B: byte;
G: byte;
R: byte;
end;
PBGRATriple = ^TBGRATriple;
var
psStep,pdStep: integer;
ps0,pd0 : Pointer; //scanline[0], row steps
sx1,sy1,sx2,sy2 : single; //source field positions
x,y,i,j: word; //source,dest field pixels
destR,destG,destB : single; //destination colors
src: TBGRATriple; //source colors
fx,fy,fix,fiy,dyf : single; //factors
fxstep,fystep, dx,dy : single;
psi,psj : Pointer;
AP : single;
istart,iend,jstart,jend : word;
devX1,devX2,devY1,devY2 : single;
DSTPIX: PBGRATriple;
begin
dstMemblock.width := newWidth;
dstMemblock.height := newHeight;
dstMemblock.colordepth := sizeof(TBGRATriple) * 8;
 
if srcMemblock.colordepth <> dstMemblock.colordepth then
begin
result := -1;
exit;
end;
 
result := 0;
 
ps0 := Pointer(srcMemblock); Inc(pbyte(ps0), SizeOf(TImgMemBlockHeader));
psstep := -srcMemblock.width * sizeof(TBGRATriple);
pd0 := Pointer(dstMemblock); Inc(pbyte(pd0), SizeOf(TImgMemBlockHeader));
pdstep := -dstMemblock.width * sizeof(TBGRATriple);
fx := srcMemblock.width/ newWidth;
fy := srcMemblock.height/newHeight;
fix := 1/fx;
fiy := 1/fy;
fxstep := 0.9999 * fx;
fystep := 0.9999 * fy;
DSTPIX := PBGRATriple(pd0);
for y := 0 to newHeight-1 do //vertical destination pixels
begin
sy1 := fy * y;
sy2 := sy1 + fystep;
jstart := trunc(sy1);
jend := trunc(sy2);
devY1 := 1-sy1+jstart;
devY2 := jend+1-sy2;
for x := 0 to newWidth-1 do //horizontal destination pixels
begin
sx1 := fx * x; //x related values are repeated
sx2 := sx1 + fxstep; //for each y and may be placed in
istart := trunc(sx1); //lookup table
iend := trunc(sx2); //...
 
if istart >= srcMemblock.width then istart := srcMemblock.width-1;
if iend >= srcMemblock.width then iend := srcMemblock.width-1;
 
devX1 := 1-sx1+istart; //...
devX2 := iend+1-sx2; //...
destR := 0; destG := 0; destB := 0; //clear destination colors
 
if jstart >= srcMemblock.height then jstart := srcMemblock.height-1;
if jend >= srcMemblock.height then jend := srcMemblock.height-1;
 
psj := ps0; dec(pbyte(psj), jstart*psStep);
dy := devY1;
 
for j := jstart to jend do //vertical source pixels
begin
if j = jend then dy := dy - devY2;
dyf := dy*fiy;
psi := psj; Inc(pbyte(psi), istart*SizeOf(TBGRATriple));
dx := devX1;
for i := istart to iend do //horizontal source pixels
begin
if i = iend then dx := dx - devX2;
AP := dx*dyf*fix;
src := PBGRATriple(psi)^;
 
destB := destB + src.B*AP;
destG := destG + src.G*AP;
destR := destR + src.R*AP;
 
inc(pbyte(psi), sizeof(TBGRATriple));
dx := 1;
end;//for i
dec(pbyte(psj),psStep);
dy := 1;
end;//for j
 
src.B := round(destB);
src.G := round(destG);
src.R := round(destR);
DSTPIX^ := src;
inc(DSTPIX, 1{element});
inc(result, SizeOf(TBGRATriple));
end;//for x
end;//for y
end;
 
function _Resize32(srcMemblock, dstMemblock: PImgMemBlockHeader; newWidth, newHeight: Cardinal): integer;
// --- Based on http://www.davdata.nl/math/bmresize.html ---
type
TBGRATriple = packed record
B: byte;
G: byte;
R: byte;
A: byte;
end;
PBGRATriple = ^TBGRATriple;
var
psStep,pdStep: integer;
ps0,pd0 : Pointer; //scanline[0], row steps
sx1,sy1,sx2,sy2 : single; //source field positions
x,y,i,j: word; //source,dest field pixels
destA,destR,destG,destB : single; //destination colors
src: TBGRATriple; //source colors
fx,fy,fix,fiy,dyf : single; //factors
fxstep,fystep, dx,dy : single;
psi,psj : Pointer;
AP : single;
istart,iend,jstart,jend : word;
devX1,devX2,devY1,devY2 : single;
DSTPIX: PBGRATriple;
begin
dstMemblock.width := newWidth;
dstMemblock.height := newHeight;
dstMemblock.colordepth := sizeof(TBGRATriple) * 8;
 
if srcMemblock.colordepth <> dstMemblock.colordepth then
begin
result := -1;
exit;
end;
 
result := 0;
 
ps0 := Pointer(srcMemblock); Inc(pbyte(ps0), SizeOf(TImgMemBlockHeader));
psstep := -srcMemblock.width * sizeof(TBGRATriple);
pd0 := Pointer(dstMemblock); Inc(pbyte(pd0), SizeOf(TImgMemBlockHeader));
pdstep := -dstMemblock.width * sizeof(TBGRATriple);
fx := srcMemblock.width/ newWidth;
fy := srcMemblock.height/newHeight;
fix := 1/fx;
fiy := 1/fy;
fxstep := 0.9999 * fx;
fystep := 0.9999 * fy;
DSTPIX := PBGRATriple(pd0);
for y := 0 to newHeight-1 do //vertical destination pixels
begin
sy1 := fy * y;
sy2 := sy1 + fystep;
jstart := trunc(sy1);
jend := trunc(sy2);
devY1 := 1-sy1+jstart;
devY2 := jend+1-sy2;
for x := 0 to newWidth-1 do //horizontal destination pixels
begin
sx1 := fx * x; //x related values are repeated
sx2 := sx1 + fxstep; //for each y and may be placed in
istart := trunc(sx1); //lookup table
iend := trunc(sx2); //...
 
if istart >= srcMemblock.width then istart := srcMemblock.width-1;
if iend >= srcMemblock.width then iend := srcMemblock.width-1;
 
devX1 := 1-sx1+istart; //...
devX2 := iend+1-sx2; //...
destR := 0; destG := 0; destB := 0; destA := 0; //clear destination colors
 
if jstart >= srcMemblock.height then jstart := srcMemblock.height-1;
if jend >= srcMemblock.height then jend := srcMemblock.height-1;
 
psj := ps0; dec(pbyte(psj), jstart*psStep);
dy := devY1;
 
for j := jstart to jend do //vertical source pixels
begin
if j = jend then dy := dy - devY2;
dyf := dy*fiy;
psi := psj; Inc(pbyte(psi), istart*SizeOf(TBGRATriple));
dx := devX1;
for i := istart to iend do //horizontal source pixels
begin
if i = iend then dx := dx - devX2;
AP := dx*dyf*fix;
src := PBGRATriple(psi)^;
 
destB := destB + src.B*AP;
destG := destG + src.G*AP;
destR := destR + src.R*AP;
destA := destA + src.A*AP;
 
inc(pbyte(psi), sizeof(TBGRATriple));
dx := 1;
end;//for i
dec(pbyte(psj),psStep);
dy := 1;
end;//for j
 
src.B := round(destB);
src.G := round(destG);
src.R := round(destR);
src.A := round(destA);
DSTPIX^ := src;
inc(DSTPIX, 1{element});
inc(result, SizeOf(TBGRATriple));
end;//for x
end;//for y
end;
 
function DestSize(memblock: PImgMemBlockHeader; newWidth, newHeight: Cardinal): integer; cdecl;
begin
if memblock.colordepth = 32 then
result := SizeOf(TImgMemBlockHeader) + newWidth * newHeight * 4
else if memblock.colordepth = 24 then
result := SizeOf(TImgMemBlockHeader) + newWidth * newHeight * 3
else
result := -1;
end;
 
function Resize(srcMemblock, dstMemblock: PImgMemBlockHeader; newWidth, newHeight: Cardinal): integer; cdecl;
begin
if srcMemblock.colordepth = 32 then
result := _Resize32(srcMemblock, dstMemblock, newWidth, newHeight)
else if srcMemblock.colordepth = 24 then
result := _Resize24(srcMemblock, dstMemblock, newWidth, newHeight)
else
result := -1;
end;
 
exports
Resize name 'Resize',
DestSize name 'DestSize';
 
end.
/trunk/dll_resize/Resize32.identcache
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/dll_resize/Resize32.res
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property