Changeset 8
- Timestamp:
- Mar 16, 2011, 10:47:36 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r7 r8 7 7 uses 8 8 Dialogs, Classes, SysUtils, Contnrs, Graphics, SpecializedMatrix, SpecializedList, 9 IntfGraphics, FPImage, LCLType, SpecializedBitmap ;9 IntfGraphics, FPImage, LCLType, SpecializedBitmap, GraphType; 10 10 11 11 const … … 96 96 FRedrawPending: Boolean; 97 97 FBitmapLower: TBitmapTColor; 98 IntfImage: TLazIntfImage; 98 99 function GetPlayerCount: Integer; 99 100 procedure SetBitmap(const AValue: TBitmap); … … 229 230 var 230 231 X, Y: Integer; 232 PixelPtr: PInteger; 233 PixelRowPtr: PInteger; 234 RawImage: TRawImage; 235 BytePerPixel: Integer; 236 P: Integer; 231 237 begin 232 238 try 233 Bitmap.BeginUpdate(True); 234 for Y := 0 to Bitmap.Height - 1 do 235 for X := 0 to Bitmap.Width - 1 do 236 Bitmap.Canvas.Pixels[X, Y] := SurfaceMatterColors[TSurfaceMatter( 237 Surface.ItemsXY[Trunc(X / Bitmap.Width * Surface.Count.X), 238 Trunc(Y / Bitmap.Height * Surface.Count.Y)])]; 239 Bitmap.BeginUpdate; 240 RawImage := Bitmap.RawImage; 241 PixelRowPtr := PInteger(RawImage.Data); 242 BytePerPixel := RawImage.Description.BitsPerPixel div 8; 243 for Y := 0 to Bitmap.Height - 1 do begin 244 PixelPtr := PixelRowPtr; 245 for X := 0 to Bitmap.Width - 1 do begin 246 P := SurfaceMatterColors[TSurfaceMatter( 247 Surface.ItemsXY[Trunc(X / Bitmap.Width * Surface.Count.X), 248 Trunc(Y / Bitmap.Height * Surface.Count.Y)])]; 249 PixelPtr^ := ((P and $ff) shl 16) or (P and $00ff00) or ((P shr 16) and $ff); 250 Inc(PByte(PixelPtr), BytePerPixel); 251 end; 252 Inc(PByte(PixelRowPtr), RawImage.Description.BytesPerLine); 253 end; 239 254 finally 240 255 Bitmap.EndUpdate; … … 591 606 begin 592 607 FBitmapLower := TBitmapTColor.Create; 608 IntfImage := TLazIntfImage.Create(1, 1); 593 609 Players := TObjectList.Create; 594 610 World := TWorld.Create; … … 600 616 begin 601 617 FBitmapLower.Free; 618 IntfImage.Free; 602 619 Players.Free; 603 620 World.Free; … … 616 633 procedure TEngine.Draw; 617 634 var 618 IntfImage: TLazIntfImage;619 635 I: Integer; 620 636 X, Y: Integer; 621 637 H, W: Integer; 622 638 Ratio: Single; 639 PixelPtr: PInteger; 640 PixelRowPtr: PInteger; 641 RawImage: TRawImage; 642 BytePerPixel: Integer; 643 P: Integer; 623 644 begin 624 645 if FRedrawPending then begin … … 627 648 TPlayer(Players[I]).Paint; 628 649 end; 629 if Assigned(FBitmap) then begin 630 //FBitmap.Canvas.StretchDraw(Rect(0, 0, FBitmap.Width, FBitmap.Height), FBitmapLower); 631 try 632 IntfImage := FBitmap.CreateIntfImage; 633 if (FBitmap.Width / FBitmapLower.Width) < (FBitmap.Height / FBitmapLower.Height) then 634 Ratio := FBitmap.Width / FBitmapLower.Width 635 else Ratio := FBitmap.Height / FBitmapLower.Height; 636 for Y := 0 to Trunc(FBitmapLower.Height * Ratio) - 1 do 637 for X := 0 to Trunc(FBitmapLower.Width * Ratio) - 1 do 638 IntfImage.Colors[X, Y] := TColorToFPColor(FBitmapLower.Pixels[Trunc(X / Ratio), Trunc(Y / Ratio)]); 639 FBitmap.LoadFromIntfImage(IntfImage); 640 finally 641 IntfImage.Free; 650 if Assigned(FBitmap) then try 651 Bitmap.BeginUpdate(False); 652 RawImage := Bitmap.RawImage; 653 PixelRowPtr := PInteger(RawImage.Data); 654 BytePerPixel := RawImage.Description.BitsPerPixel div 8; 655 if (IntfImage.Width <> FBitmap.Width) or (IntfImage.Height <> FBitmap.Height) then 656 IntfImage.SetSize(FBitmap.Width, FBitmap.Height); 657 if (FBitmap.Width / FBitmapLower.Width) < (FBitmap.Height / FBitmapLower.Height) then 658 Ratio := FBitmap.Width / FBitmapLower.Width 659 else Ratio := FBitmap.Height / FBitmapLower.Height; 660 for Y := 0 to Trunc(FBitmapLower.Height * Ratio) - 1 do begin 661 PixelPtr := PixelRowPtr; 662 for X := 0 to Trunc(FBitmapLower.Width * Ratio) - 1 do begin 663 P := FBitmapLower.Pixels[Trunc(X / Ratio), Trunc(Y / Ratio)]; 664 PixelPtr^ := ((P and $ff) shl 16) or (P and $00ff00) or ((P shr 16) and $ff); 665 Inc(PByte(PixelPtr), BytePerPixel); 666 end; 667 Inc(PByte(PixelRowPtr), RawImage.Description.BytesPerLine); 642 668 end; 669 finally 670 FBitmap.EndUpdate(False); 643 671 end; 644 672 FRedrawPending := False; -
trunk/tunneler.lpi
r7 r8 42 42 </Item3> 43 43 </RequiredPackages> 44 <Units Count="4 0">44 <Units Count="41"> 45 45 <Unit0> 46 46 <Filename Value="tunneler.lpr"/> … … 50 50 <TopLine Value="1"/> 51 51 <CursorPos X="14" Y="8"/> 52 <UsageCount Value=" 58"/>52 <UsageCount Value="60"/> 53 53 </Unit0> 54 54 <Unit1> … … 58 58 <ResourceBaseClass Value="Form"/> 59 59 <UnitName Value="UMainForm"/> 60 <IsVisibleTab Value="True"/> 61 <EditorIndex Value="13"/> 62 <WindowIndex Value="0"/> 63 <TopLine Value="22"/> 64 <CursorPos X="20" Y="36"/> 65 <UsageCount Value="58"/> 60 <EditorIndex Value="7"/> 61 <WindowIndex Value="0"/> 62 <TopLine Value="81"/> 63 <CursorPos X="3" Y="90"/> 64 <UsageCount Value="60"/> 66 65 <Loaded Value="True"/> 67 66 <LoadedDesigner Value="True"/> … … 71 70 <IsPartOfProject Value="True"/> 72 71 <UnitName Value="UCore"/> 72 <IsVisibleTab Value="True"/> 73 73 <EditorIndex Value="0"/> 74 74 <WindowIndex Value="0"/> 75 <TopLine Value=" 317"/>76 <CursorPos X=" 44" Y="326"/>77 <UsageCount Value=" 58"/>75 <TopLine Value="229"/> 76 <CursorPos X="1" Y="250"/> 77 <UsageCount Value="60"/> 78 78 <Loaded Value="True"/> 79 79 </Unit2> … … 114 114 <EditorIndex Value="1"/> 115 115 <WindowIndex Value="0"/> 116 <TopLine Value=" 1293"/>117 <CursorPos X=" 15" Y="1310"/>116 <TopLine Value="2417"/> 117 <CursorPos X="3" Y="2459"/> 118 118 <UsageCount Value="12"/> 119 119 <Loaded Value="True"/> … … 121 121 <Unit8> 122 122 <Filename Value="../../../lazarus/lcl/include/rasterimage.inc"/> 123 <EditorIndex Value="2"/>124 123 <WindowIndex Value="0"/> 125 124 <TopLine Value="548"/> 126 125 <CursorPos X="22" Y="552"/> 127 126 <UsageCount Value="10"/> 128 <Loaded Value="True"/>129 127 </Unit8> 130 128 <Unit9> … … 145 143 <Unit11> 146 144 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericMatrix.inc"/> 147 <EditorIndex Value=" 14"/>145 <EditorIndex Value="8"/> 148 146 <WindowIndex Value="0"/> 149 147 <TopLine Value="52"/> … … 155 153 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Specialized/SpecializedMatrix.pas"/> 156 154 <UnitName Value="SpecializedMatrix"/> 157 <EditorIndex Value="1 6"/>155 <EditorIndex Value="10"/> 158 156 <WindowIndex Value="0"/> 159 157 <TopLine Value="16"/> … … 179 177 <Unit15> 180 178 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericList.inc"/> 181 <EditorIndex Value=" 11"/>179 <EditorIndex Value="5"/> 182 180 <WindowIndex Value="0"/> 183 181 <TopLine Value="473"/> … … 239 237 <Unit23> 240 238 <Filename Value="../../../lazarus/lcl/include/lclintfh.inc"/> 241 <EditorIndex Value="6"/>242 239 <WindowIndex Value="0"/> 243 240 <TopLine Value="85"/> 244 241 <CursorPos X="10" Y="102"/> 245 242 <UsageCount Value="10"/> 246 <Loaded Value="True"/>247 243 </Unit23> 248 244 <Unit24> 249 245 <Filename Value="../../../lazarus/lcl/include/lclintf.inc"/> 250 <EditorIndex Value="7"/>251 246 <WindowIndex Value="0"/> 252 247 <TopLine Value="157"/> 253 248 <CursorPos X="3" Y="159"/> 254 249 <UsageCount Value="10"/> 255 <Loaded Value="True"/>256 250 </Unit24> 257 251 <Unit25> … … 275 269 <ResourceBaseClass Value="Form"/> 276 270 <UnitName Value="UMapForm"/> 277 <EditorIndex Value=" 12"/>271 <EditorIndex Value="6"/> 278 272 <WindowIndex Value="0"/> 279 273 <TopLine Value="15"/> 280 <CursorPos X=" 1" Y="38"/>281 <UsageCount Value="3 7"/>274 <CursorPos X="20" Y="39"/> 275 <UsageCount Value="39"/> 282 276 <Loaded Value="True"/> 283 277 </Unit27> … … 305 299 <Unit31> 306 300 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericListObject.inc"/> 307 <EditorIndex Value="1 7"/>301 <EditorIndex Value="11"/> 308 302 <WindowIndex Value="0"/> 309 303 <TopLine Value="1"/> … … 315 309 <Filename Value="../../../lazarus/lcl/intfgraphics.pas"/> 316 310 <UnitName Value="IntfGraphics"/> 317 <EditorIndex Value="3"/> 318 <WindowIndex Value="0"/> 319 <TopLine Value="106"/> 320 <CursorPos X="30" Y="113"/> 321 <UsageCount Value="10"/> 322 <Loaded Value="True"/> 311 <WindowIndex Value="0"/> 312 <TopLine Value="3371"/> 313 <CursorPos X="24" Y="3388"/> 314 <UsageCount Value="10"/> 323 315 </Unit32> 324 316 <Unit33> 325 317 <Filename Value="/usr/share/fpcsrc/2.4.0/packages/fcl-image/src/fpimage.pp"/> 326 318 <UnitName Value="FPimage"/> 327 <EditorIndex Value="5"/>328 319 <WindowIndex Value="0"/> 329 320 <TopLine Value="104"/> 330 321 <CursorPos X="3" Y="91"/> 331 322 <UsageCount Value="10"/> 332 <Loaded Value="True"/>333 323 </Unit33> 334 324 <Unit34> … … 342 332 <Filename Value="../../../lazarus/lcl/graphtype.pp"/> 343 333 <UnitName Value="GraphType"/> 344 <EditorIndex Value="4"/>345 334 <WindowIndex Value="0"/> 346 335 <TopLine Value="191"/> 347 336 <CursorPos X="3" Y="188"/> 348 337 <UsageCount Value="10"/> 349 <Loaded Value="True"/>350 338 </Unit35> 351 339 <Unit36> 352 340 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericBitmap.inc"/> 353 <UnitName Value="GenericBitmap"/> 354 <EditorIndex Value="10"/> 341 <EditorIndex Value="4"/> 355 342 <WindowIndex Value="0"/> 356 343 <TopLine Value="9"/> … … 362 349 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Specialized/SpecializedBitmap.pas"/> 363 350 <UnitName Value="SpecializedBitmap"/> 364 <EditorIndex Value=" 8"/>351 <EditorIndex Value="2"/> 365 352 <WindowIndex Value="0"/> 366 353 <TopLine Value="3"/> … … 372 359 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Specialized/SpecializedList.pas"/> 373 360 <UnitName Value="SpecializedList"/> 374 <EditorIndex Value=" 9"/>361 <EditorIndex Value="3"/> 375 362 <WindowIndex Value="0"/> 376 363 <TopLine Value="91"/> … … 381 368 <Unit39> 382 369 <Filename Value="../../PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericListString.inc"/> 383 <EditorIndex Value=" 15"/>370 <EditorIndex Value="9"/> 384 371 <WindowIndex Value="0"/> 385 372 <TopLine Value="1"/> … … 388 375 <Loaded Value="True"/> 389 376 </Unit39> 377 <Unit40> 378 <Filename Value="/usr/share/fpcsrc/2.4.0/rtl/inc/objpash.inc"/> 379 <WindowIndex Value="0"/> 380 <TopLine Value="158"/> 381 <CursorPos X="23" Y="175"/> 382 <UsageCount Value="10"/> 383 </Unit40> 390 384 </Units> 391 <JumpHistory Count="2 7" HistoryIndex="26">385 <JumpHistory Count="29" HistoryIndex="28"> 392 386 <Position1> 393 <Filename Value="U Core.pas"/>394 <Caret Line="6 15" Column="8" TopLine="607"/>387 <Filename Value="UMainForm.pas"/> 388 <Caret Line="67" Column="6" TopLine="48"/> 395 389 </Position1> 396 390 <Position2> 397 391 <Filename Value="UCore.pas"/> 398 <Caret Line=" 634" Column="1" TopLine="607"/>392 <Caret Line="126" Column="14" TopLine="109"/> 399 393 </Position2> 400 394 <Position3> 401 395 <Filename Value="UCore.pas"/> 402 <Caret Line=" 635" Column="1" TopLine="607"/>396 <Caret Line="99" Column="24" TopLine="82"/> 403 397 </Position3> 404 398 <Position4> 405 399 <Filename Value="UCore.pas"/> 406 <Caret Line=" 636" Column="1" TopLine="608"/>400 <Caret Line="530" Column="28" TopLine="530"/> 407 401 </Position4> 408 402 <Position5> 409 403 <Filename Value="UCore.pas"/> 410 <Caret Line=" 637" Column="1" TopLine="609"/>404 <Caret Line="99" Column="39" TopLine="95"/> 411 405 </Position5> 412 406 <Position6> 413 407 <Filename Value="UCore.pas"/> 414 <Caret Line=" 626" Column="29" TopLine="610"/>408 <Caret Line="530" Column="50" TopLine="530"/> 415 409 </Position6> 416 410 <Position7> 417 411 <Filename Value="UCore.pas"/> 418 <Caret Line=" 324" Column="21" TopLine="317"/>412 <Caret Line="629" Column="24" TopLine="612"/> 419 413 </Position7> 420 414 <Position8> 421 415 <Filename Value="UCore.pas"/> 422 <Caret Line=" 432" Column="8" TopLine="417"/>416 <Caret Line="98" Column="6" TopLine="93"/> 423 417 </Position8> 424 418 <Position9> 425 419 <Filename Value="UCore.pas"/> 426 <Caret Line=" 434" Column="10" TopLine="417"/>420 <Caret Line="105" Column="15" TopLine="94"/> 427 421 </Position9> 428 422 <Position10> 429 <Filename Value="U MainForm.pas"/>430 <Caret Line=" 87" Column="27" TopLine="61"/>423 <Filename Value="UCore.pas"/> 424 <Caret Line="632" Column="59" TopLine="615"/> 431 425 </Position10> 432 426 <Position11> 433 <Filename Value="U MainForm.pas"/>434 <Caret Line=" 86" Column="27" TopLine="60"/>427 <Filename Value="UCore.pas"/> 428 <Caret Line="634" Column="32" TopLine="616"/> 435 429 </Position11> 436 430 <Position12> 437 <Filename Value="U MainForm.pas"/>438 <Caret Line=" 87" Column="27" TopLine="61"/>431 <Filename Value="UCore.pas"/> 432 <Caret Line="637" Column="14" TopLine="620"/> 439 433 </Position12> 440 434 <Position13> 441 <Filename Value="U MainForm.pas"/>442 <Caret Line="6 7" Column="6" TopLine="48"/>435 <Filename Value="UCore.pas"/> 436 <Caret Line="638" Column="38" TopLine="621"/> 443 437 </Position13> 444 438 <Position14> 445 <Filename Value="U Core.pas"/>446 <Caret Line="1 26" Column="14" TopLine="109"/>439 <Filename Value="UMainForm.pas"/> 440 <Caret Line="174" Column="1" TopLine="153"/> 447 441 </Position14> 448 442 <Position15> 449 <Filename Value="U Core.pas"/>450 <Caret Line=" 99" Column="24" TopLine="82"/>443 <Filename Value="UMainForm.pas"/> 444 <Caret Line="175" Column="1" TopLine="154"/> 451 445 </Position15> 452 446 <Position16> 453 447 <Filename Value="UCore.pas"/> 454 <Caret Line=" 530" Column="28" TopLine="530"/>448 <Caret Line="639" Column="38" TopLine="616"/> 455 449 </Position16> 456 450 <Position17> 457 451 <Filename Value="UCore.pas"/> 458 <Caret Line=" 99" Column="39" TopLine="95"/>452 <Caret Line="634" Column="1" TopLine="622"/> 459 453 </Position17> 460 454 <Position18> 461 455 <Filename Value="UCore.pas"/> 462 <Caret Line=" 530" Column="50" TopLine="530"/>456 <Caret Line="636" Column="1" TopLine="622"/> 463 457 </Position18> 464 458 <Position19> 465 459 <Filename Value="UCore.pas"/> 466 <Caret Line="6 29" Column="24" TopLine="612"/>460 <Caret Line="637" Column="1" TopLine="622"/> 467 461 </Position19> 468 462 <Position20> 469 463 <Filename Value="UCore.pas"/> 470 <Caret Line=" 98" Column="6" TopLine="93"/>464 <Caret Line="638" Column="1" TopLine="622"/> 471 465 </Position20> 472 466 <Position21> 473 467 <Filename Value="UCore.pas"/> 474 <Caret Line=" 105" Column="15" TopLine="94"/>468 <Caret Line="632" Column="83" TopLine="622"/> 475 469 </Position21> 476 470 <Position22> 477 471 <Filename Value="UCore.pas"/> 478 <Caret Line=" 632" Column="59" TopLine="615"/>472 <Caret Line="594" Column="41" TopLine="577"/> 479 473 </Position22> 480 474 <Position23> 481 475 <Filename Value="UCore.pas"/> 482 <Caret Line="6 34" Column="32" TopLine="616"/>476 <Caret Line="641" Column="10" TopLine="612"/> 483 477 </Position23> 484 478 <Position24> 485 479 <Filename Value="UCore.pas"/> 486 <Caret Line="6 37" Column="14" TopLine="620"/>480 <Caret Line="629" Column="1" TopLine="621"/> 487 481 </Position24> 488 482 <Position25> 489 483 <Filename Value="UCore.pas"/> 490 <Caret Line=" 638" Column="38" TopLine="621"/>484 <Caret Line="9" Column="54" TopLine="1"/> 491 485 </Position25> 492 486 <Position26> 493 <Filename Value="U MainForm.pas"/>494 <Caret Line=" 174" Column="1" TopLine="153"/>487 <Filename Value="UCore.pas"/> 488 <Caret Line="628" Column="15" TopLine="622"/> 495 489 </Position26> 496 490 <Position27> 497 <Filename Value="U MainForm.pas"/>498 <Caret Line=" 175" Column="1" TopLine="154"/>491 <Filename Value="UCore.pas"/> 492 <Caret Line="647" Column="32" TopLine="633"/> 499 493 </Position27> 494 <Position28> 495 <Filename Value="UCore.pas"/> 496 <Caret Line="649" Column="49" TopLine="617"/> 497 </Position28> 498 <Position29> 499 <Filename Value="UMapForm.pas"/> 500 <Caret Line="39" Column="20" TopLine="15"/> 501 </Position29> 500 502 </JumpHistory> 501 503 </ProjectOptions>
Note:
See TracChangeset
for help on using the changeset viewer.