Changeset 315 for trunk/Packages/CevoComponents/ScreenTools.pas
- Timestamp:
- Mar 18, 2021, 10:58:28 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CevoComponents/ScreenTools.pas
r314 r315 40 40 function LoadGraphicFile(Bmp: TBitmap; FileName: string; Options: TLoadGraphicFileOptions = []): boolean; 41 41 function LoadGraphicSet(const Name: string): TGraphicSet; 42 function LoadGraphicSet2(const Name: string): TGraphicSet; 42 43 procedure Dump(dst: TBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer); 43 44 procedure Sprite(Canvas: TCanvas; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer); … … 107 108 108 109 const 110 TransparentColor1 = $FF00FF; 111 TransparentColor2 = $7F007F; 112 109 113 wMainTexture = 640; 110 114 hMainTexture = 480; 111 115 112 // template positions in Template .bmp116 // template positions in Templates.png 113 117 xLogo = 1; 114 118 yLogo = 1; … … 172 176 CityMark2: TGraphicSetItem; 173 177 Ornament: TGraphicSetItem; 178 Logo: TGraphicSetItem; 174 179 ClickFrameColor: Integer; 175 180 MainTextureAge: Integer; 176 181 MainTexture: TTexture; 177 Templates: T Bitmap;182 Templates: TGraphicSet; 178 183 Colors: TBitmap; 179 184 Paper: TBitmap; … … 474 479 x: Integer; 475 480 y: Integer; 476 xmax: Integer;477 481 OriginalColor: Integer; 478 482 FileName: string; … … 484 488 Result := GrExt.AddNew(Name); 485 489 FileName := GetGraphicsDir + DirectorySeparator + Name; 486 if not LoadGraphicFile(Result.Data, FileName) then begin 490 // Do not apply gamma during file load as it would affect also transparency colors 491 if not LoadGraphicFile(Result.Data, FileName, [gfNoGamma]) then begin 487 492 Result := nil; 488 493 Exit; … … 494 499 495 500 Result.ResetPixUsed; 496 497 xmax := Result.Data.Width - 1; // allows 4-byte access even for last pixel498 // Why there was that limit?499 //if xmax > 970 then500 // xmax := 970;501 501 502 502 Result.Mask.SetSize(Result.Data.Width, Result.Data.Height); … … 507 507 MaskPixel := PixelPointer(Result.Mask); 508 508 for y := 0 to ScaleToNative(Result.Data.Height) - 1 do begin 509 for x := 0 to ScaleToNative( xmax) - 1 do begin509 for x := 0 to ScaleToNative(Result.Data.Width) - 1 do begin 510 510 OriginalColor := DataPixel.Pixel^.ARGB and $FFFFFF; 511 if (OriginalColor = $FF00FF) or (OriginalColor = $7F007F) then 512 begin // transparent 513 MaskPixel.Pixel^.ARGB := $FFFFFF; 514 DataPixel.Pixel^.ARGB := DataPixel.Pixel^.ARGB and $FF000000; 515 end 516 else begin 517 MaskPixel.Pixel^.ARGB := $000000; // non-transparent 518 if Gamma <> 100 then 519 DataPixel.Pixel^ := ApplyGammaToPixel(DataPixel.Pixel^); 511 if (OriginalColor = TransparentColor1) or (OriginalColor = TransparentColor2) then begin 512 MaskPixel.Pixel^.R := $FF; 513 MaskPixel.Pixel^.G := $FF; 514 MaskPixel.Pixel^.B := $FF; 515 DataPixel.Pixel^.R := 0; 516 DataPixel.Pixel^.G := 0; 517 DataPixel.Pixel^.B := 0; 518 end else begin 519 MaskPixel.Pixel^.R := $00; 520 MaskPixel.Pixel^.G := $00; 521 MaskPixel.Pixel^.B := $00; 520 522 end; 521 523 DataPixel.NextPixel; … … 527 529 Result.Data.EndUpdate; 528 530 Result.Mask.EndUpdate; 531 532 if Gamma <> 100 then 533 ApplyGammaToBitmap(Result.Data); 534 end; 535 end; 536 537 function LoadGraphicSet2(const Name: string): TGraphicSet; 538 var 539 FileName: string; 540 begin 541 Result := GrExt.SearchByName(Name); 542 if not Assigned(Result) then begin 543 Result := GrExt.AddNew(Name); 544 FileName := GetGraphicsDir + DirectorySeparator + Name; 545 if not LoadGraphicFile(Result.Data, FileName, [gfNoGamma]) then begin 546 Result := nil; 547 Exit; 548 end; 549 550 FileName := ExtractFileNameWithoutExt(FileName) + GraphicSetFileExt; 551 if FileExists(FileName) then 552 Result.LoadFromFile(FileName); 553 554 Result.ResetPixUsed; 529 555 end; 530 556 end; … … 1114 1140 procedure Corner(ca: TCanvas; x, y, Kind: Integer; const T: TTexture); 1115 1141 begin 1116 { BitBltCanvas(ca,x,y,8,8, GrExt[T.HGr].Mask.Canvas,1142 { BitBltCanvas(ca,x,y,8,8,T.HGr.Mask.Canvas, 1117 1143 T.xGr+29+Kind*9,T.yGr+89,SRCAND); 1118 BitBltCanvas(ca,x,y,8,8, GrExt[T.HGr].Data.Canvas,1144 BitBltCanvas(ca,x,y,8,8,T.HGr.Data.Canvas, 1119 1145 T.xGr+29+Kind*9,T.yGr+89,SRCPAINT); } 1120 1146 end; … … 1134 1160 sp: string; 1135 1161 shadow: Boolean; 1162 Text: string; 1136 1163 begin 1137 1164 Inc(x); … … 1157 1184 else 1158 1185 begin 1159 Textout(xp, y, copy(sp, 1, p - 1)); 1160 Inc(xp, ca.TextWidth(copy(sp, 1, p - 1))); 1186 Text := Copy(sp, 1, p - 1); 1187 Textout(xp, y, Text); 1188 Inc(xp, ca.TextWidth(Text)); 1161 1189 if not shadow then 1162 1190 case sp[p + 1] of … … 1471 1499 LogoBuffer.Canvas.FillRect(0, 0, LogoBuffer.Width, LogoBuffer.Height); 1472 1500 BitBltCanvas(LogoBuffer.Canvas, 0, 0, wLogo, hLogo, ca, x, y); 1473 ImageOp_BCC(LogoBuffer, Templates , 0, 0, 1, 1, wLogo, hLogo,1501 ImageOp_BCC(LogoBuffer, Templates.Data, 0, 0, 1, 1, wLogo, hLogo, 1474 1502 clLight, clShade); 1475 1503 BitBltCanvas(ca, x, y, wLogo, hLogo, LogoBuffer.Canvas, 0, 0); … … 1653 1681 LoadPhrases; 1654 1682 LoadFonts; 1655 LoadGraphicFile(Templates, GetGraphicsDir + DirectorySeparator + 1656 'Templates.png', [gfNoGamma]); 1683 Templates := LoadGraphicSet2('Templates.png'); 1657 1684 LoadGraphicFile(Colors, GetGraphicsDir + DirectorySeparator + 'Colors.png'); 1658 1685 LoadGraphicFile(Paper, GetGraphicsDir + DirectorySeparator + 'Paper.jpg'); … … 1688 1715 Ornament := HGrSystem2.GetItem('Ornament'); 1689 1716 1690 Templates := TBitmap.Create;1691 Templates.PixelFormat := pf24bit;1692 1717 Colors := TBitmap.Create; 1693 1718 Colors.PixelFormat := pf24bit; … … 1706 1731 1707 1732 procedure UnitDone; 1708 var1709 I: Integer;1710 1733 begin 1711 1734 RestoreResolution; … … 1717 1740 FreeAndNil(BigImp); 1718 1741 FreeAndNil(Paper); 1719 FreeAndNil(Templates);1720 1742 FreeAndNil(Colors); 1721 1743 FreeAndNil(MainTexture.Image);
Note:
See TracChangeset
for help on using the changeset viewer.