Fixed view in Random palette.

This commit is contained in:
meffi@lab313.ru
2015-03-08 14:55:38 +00:00
parent 951f67e802
commit 42d231472b
4 changed files with 24 additions and 204 deletions

View File

@@ -1,182 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectSession>
<PathDelim Value="\"/>
<Version Value="9"/>
<BuildModes Active="Win Release x86"/>
<Units Count="15">
<Unit0>
<Filename Value="tim2view.lpr"/>
<IsPartOfProject Value="True"/>
<CursorPos X="46" Y="13"/>
<UsageCount Value="816"/>
</Unit0>
<Unit1>
<Filename Value="umain.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="frmMain"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="umain"/>
<TopLine Value="554"/>
<CursorPos X="59" Y="566"/>
<UsageCount Value="816"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="edc.pas"/>
<IsPartOfProject Value="True"/>
<UsageCount Value="816"/>
</Unit2>
<Unit3>
<Filename Value="ecc.pas"/>
<IsPartOfProject Value="True"/>
<TopLine Value="13"/>
<UsageCount Value="816"/>
</Unit3>
<Unit4>
<Filename Value="ucommon.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ucommon"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
<CursorPos X="71" Y="11"/>
<UsageCount Value="816"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="utim.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="utim"/>
<EditorIndex Value="10"/>
<TopLine Value="384"/>
<CursorPos Y="401"/>
<UsageCount Value="816"/>
<Loaded Value="True"/>
</Unit5>
<Unit6>
<Filename Value="ucdimage.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ucdimage"/>
<EditorIndex Value="2"/>
<TopLine Value="112"/>
<CursorPos X="50" Y="117"/>
<UsageCount Value="816"/>
<Loaded Value="True"/>
</Unit6>
<Unit7>
<Filename Value="usettings.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="usettings"/>
<EditorIndex Value="9"/>
<CursorPos X="15" Y="59"/>
<UsageCount Value="816"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
<Filename Value="uscanresult.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="uscanresult"/>
<EditorIndex Value="7"/>
<TopLine Value="56"/>
<CursorPos Y="71"/>
<UsageCount Value="816"/>
<Loaded Value="True"/>
</Unit8>
<Unit9>
<Filename Value="uscanthread.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="uscanthread"/>
<EditorIndex Value="8"/>
<TopLine Value="18"/>
<CursorPos X="37" Y="68"/>
<UsageCount Value="816"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
<Filename Value="ucpucount.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ucpucount"/>
<EditorIndex Value="4"/>
<TopLine Value="19"/>
<CursorPos X="87" Y="34"/>
<UsageCount Value="816"/>
<Loaded Value="True"/>
</Unit10>
<Unit11>
<Filename Value="udrawtim.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="udrawtim"/>
<EditorIndex Value="5"/>
<CursorPos X="15" Y="212"/>
<UsageCount Value="816"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
<Filename Value="bgrabitmap\bgrabitmap.pas"/>
<IsPartOfProject Value="True"/>
<TopLine Value="54"/>
<CursorPos X="3" Y="69"/>
<UsageCount Value="816"/>
</Unit12>
<Unit13>
<Filename Value="todos.inc"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<CursorPos X="31" Y="3"/>
<UsageCount Value="802"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
<Filename Value="uexportimport.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="uexportimport"/>
<EditorIndex Value="6"/>
<TopLine Value="7"/>
<CursorPos X="32" Y="35"/>
<UsageCount Value="98"/>
<Loaded Value="True"/>
</Unit14>
</Units>
</ProjectSession>
<Debugging>
<BreakPoints Count="3">
<Item1>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="c:\Lazarus\fpc\2.6.2\source\packages\fcl-image\src\fpimage.inc"/>
<Line Value="350"/>
</Item1>
<Item2>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="c:\Lazarus\fpc\2.6.2\source\packages\fcl-image\src\fppalette.inc"/>
<Line Value="159"/>
</Item2>
<Item3>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="usettings.pas"/>
<Line Value="74"/>
</Item3>
</BreakPoints>
<Watches Count="3">
<Item1>
<Expression Value="IDX"/>
<DisplayStyle Value="wdfHex"/>
</Item1>
<Item2>
<Expression Value="TData^[POS]"/>
<DisplayStyle Value="wdfHex"/>
</Item2>
<Item3>
<Expression Value="IDX_INT"/>
<DisplayStyle Value="wdfHex"/>
</Item3>
</Watches>
</Debugging>
</CONFIG>

View File

@@ -76,9 +76,9 @@ var
R, G, B, A: Byte;
FC: TFPColor;
begin
if (TIM^.HEAD^.bBPP in [cTIM16NC, cTIM24NC]) then Exit;
if (TIM^.OverBpp in [cTIM16NC, cTIM24NC]) then Exit;
if (TIM^.HEAD^.bBPP in [cTIM4NC, cTIM8NC]) then
if (TIM^.OverBpp in [cTIM4NC, cTIM8NC]) then
begin
Randomize;
COUNT := 256;
@@ -130,7 +130,7 @@ begin
RW := GetTimRealWidth(TIM);
WH := TIM^.IMAGE^.wWidth * TIM^.IMAGE^.wHeight;
case TIM^.HEAD^.bBPP of
case TIM^.OverBpp of
cTIM4C, cTIM4NC:
for I := 1 to WH * 2 do
begin
@@ -198,7 +198,7 @@ begin
if (Image^ <> nil) then Image^.Free;
Image^ := TBGRABitmap.Create(RW, RH);
Image^.UsePalette := not(TIM^.HEAD^.bBPP in [cTIM16NC, cTIM24NC]);
Image^.UsePalette := not(TIM^.OverBpp in [cTIM16NC, cTIM24NC]);
PAL := @(Image^.Palette);
@@ -216,7 +216,7 @@ begin
for Y := 1 to RH do
for X := 1 to RW do
begin
case TIM^.HEAD^.bBPP of
case TIM^.OverBpp of
cTIM4C, cTIM4NC, cTIM8C, cTIM8NC:
Image^.Pixels[X - 1, Y - 1] := INDEXES^[IDX] mod COLORS;
cTIM16C, cTIM16NC, cTIMMixC, cTIMMixNC:

View File

@@ -280,7 +280,7 @@ begin
5: cbbBitMode.Tag := NativeInt(cTIM16NC);
6: cbbBitMode.Tag := NativeInt(cTIM24NC);
else
cbbBitMode.Tag := NativeInt($FF);
cbbBitMode.Tag := NativeInt(-1);
end;
UpdateTim(True, False, False);
@@ -555,7 +555,7 @@ procedure TfrmMain.FormCreate(Sender: TObject);
begin
Settings := TSettings.Create(ExtractFilePath(ParamStr(0)));
cbbBitMode.Tag := NativeInt($FF);
cbbBitMode.Tag := NativeInt(-1);
{$IFDEF windows}actAddToSendto.Checked := Settings.SendToShortcutExists;{$ENDIF}
actStretch.Checked := Settings.StretchMode;
@@ -755,8 +755,10 @@ begin
P := SelectedTimInfo.Position;
Result := LoadTimFromFile(SelectedScanResult.ScanFile, P, SelectedScanResult.IsImage, SelectedTimInfo.Size);
if Integer(cbbBitMode.Tag) = $FF then Exit;
Result^.HEAD^.bBPP := Integer(cbbBitMode.Tag);
if Integer(cbbBitMode.Tag) = -1 then
Result^.OverBpp := Result^.HEAD^.bBPP
else
Result^.OverBpp := Integer(cbbBitMode.Tag);
end;
procedure TfrmMain.ScanPath(const Path: string);

View File

@@ -105,10 +105,7 @@ type
IMAGE: PIMAGEHeader;
dwSize: Integer;
DATA: PTIMDataArray;
UseExtClut: Boolean;
ExtCLUT: PCLUTHeader;
ExtCLUT_DATA: PCLUT_COLORS;
OverBpp: Integer;
end;
PTIM = ^TTIM;
@@ -168,7 +165,7 @@ var
CLUT_OFFSET: Integer;
COLOR: word;
begin
if (TIM^.HEAD^.bBPP in [cTIM4NC, cTIM8NC]) then
if (TIM^.OverBpp in [cTIM4NC, cTIM8NC]) then
begin
Result.R := random($20) shl 3;
Result.G := random($20) shl 3;
@@ -272,8 +269,15 @@ begin
end;
function IWidthToRWidth(TIM: PTIM): word;
var
bpp: Integer;
begin
case TIM^.HEAD^.bBPP of
if (TIM^.HEAD^.bBPP <> TIM^.OverBpp) then
bpp := TIM^.OverBpp
else
bpp := TIM^.HEAD^.bBPP;
case bpp of
cTIM4C, cTIM4NC: Result := (TIM^.IMAGE^.wWidth * 4) and $FFFF;
cTIM8C, cTIM8NC: Result := (TIM^.IMAGE^.wWidth * 2) and $FFFF;
cTIM16C, cTIM16NC, cTIMMixC, cTIMMixNC: Result := TIM^.IMAGE^.wWidth;
@@ -410,10 +414,7 @@ begin
Move(PBytesArray(BUFFER)^[TIM_POS], TIM^.DATA^[0], TIM^.dwSize);
TIM^.UseExtClut := False;
TIM^.ExtCLUT := nil;
TIM^.ExtCLUT_DATA := nil;
TIM^.OverBpp := TIM^.HEAD^.bBPP;
Result := True;
end;
@@ -473,6 +474,7 @@ begin
P := 0;
Result := nil;
LoadTimFromBuf(TIM_BUF, Result, P);
sImageStream.Free;
Dispose(TIM_BUF);
@@ -536,9 +538,7 @@ begin
Result^.dwSize := 0;
Result^.dwTimPosition := 0;
Result^.dwTimNumber := 0;
Result^.UseExtClut := False;
Result^.ExtCLUT := nil;
Result^.ExtCLUT_DATA := nil;
Result^.OverBpp := -1;
New(Result^.DATA);
ClearTIM(Result);
end;