- Timestamp:
- Sep 19, 2014, 9:47:22 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormNew.pas
r2 r8 47 47 ColorFormat: TGColorFormat; 48 48 begin 49 ColorFormat := ColorManager.Formats[ComboBoxColorFormat.ItemIndex] .Create;50 LabelMemRequire.Caption := IntToStr(SpinEditWidth.Value * SpinEditHeight.Value * ColorFormat.GetBitDepth div 8) + ' bytes';51 ColorFormat.Free;49 ColorFormat := ColorManager.Formats[ComboBoxColorFormat.ItemIndex]; 50 LabelMemRequire.Caption := IntToStr(SpinEditWidth.Value * SpinEditHeight.Value * 51 ColorFormat.GetBitDepth div 8) + ' bytes'; 52 52 end; 53 53 … … 59 59 ComboBoxColorFormat.Clear; 60 60 for I := 0 to ColorManager.FormatCount - 1 do begin 61 ColorFormat := ColorManager.Formats[I] .Create;61 ColorFormat := ColorManager.Formats[I]; 62 62 ComboBoxColorFormat.AddItem(ColorFormat.GetName, nil); 63 ColorFormat.Free;64 63 end; 65 64 if ComboBoxColorFormat.Items.Count > 0 then -
trunk/LibrePaint.lpi
r7 r8 99 99 <HasResources Value="True"/> 100 100 <ResourceBaseClass Value="Form"/> 101 <UnitName Value="UFormNew"/> 101 102 </Unit4> 102 103 <Unit5> -
trunk/UCore.pas
r7 r8 74 74 begin 75 75 if FormNew.ShowModal = mrOk then begin 76 Project.Bitmap.ColorFormat := TGColorFormat ;76 Project.Bitmap.ColorFormat := TGColorFormat.Create; 77 77 78 78 Project.FileName := 'New image'; -
trunk/UGraphic.pas
r7 r8 36 36 TGColor = class 37 37 private 38 FColorFormat: TGColorFormat Class;38 FColorFormat: TGColorFormat; 39 39 FData: PByte; 40 40 function GetChannel(Channel: TGColorChannel): TGColor; 41 procedure SetColorFormat(AValue: TGColorFormat Class);41 procedure SetColorFormat(AValue: TGColorFormat); 42 42 procedure LoadData(BitmapData: Pointer); virtual; 43 43 procedure SaveData(BitmapData: Pointer); virtual; … … 50 50 property Data: PByte read FData; 51 51 published 52 property Format: TGColorFormat Classread FColorFormat write SetColorFormat;52 property Format: TGColorFormat read FColorFormat write SetColorFormat; 53 53 end; 54 54 … … 59 59 FBackgroundColor: TGColor; 60 60 FCanvas: TGCanvas; 61 FColorFormat: TGColorFormat Class;61 FColorFormat: TGColorFormat; 62 62 FDPI: Integer; 63 63 FSize: TPoint; … … 66 66 function GetSize: TPoint; 67 67 procedure SetBackgroundColor(AValue: TGColor); 68 procedure SetColorFormat(AValue: TGColorFormat Class);68 procedure SetColorFormat(AValue: TGColorFormat); 69 69 procedure SetPixel(X, Y: Integer; AValue: TGColor); 70 70 procedure SetSize(AValue: TPoint); … … 81 81 property BackgroundColor: TGColor read FBackgroundColor write SetBackgroundColor; 82 82 property DPI: Integer read FDPI write FDPI; 83 property ColorFormat: TGColorFormat Classread FColorFormat write SetColorFormat;83 property ColorFormat: TGColorFormat read FColorFormat write SetColorFormat; 84 84 property Size: TPoint read FSize write SetSize; 85 85 property Pixels[X, Y: Integer]: TGColor read GetPixel write SetPixel; … … 93 93 private 94 94 FFormats: TObjectList; // TList<TGColorFormatClass> 95 function GetFormat(Index: Integer): TGColorFormat Class;95 function GetFormat(Index: Integer): TGColorFormat; 96 96 public 97 97 constructor Create; virtual; … … 99 99 procedure RegisterFormat(Format: TGColorFormatClass); 100 100 function FormatCount: Integer; 101 property Formats[Index: Integer]: TGColorFormat Classread GetFormat;101 property Formats[Index: Integer]: TGColorFormat read GetFormat; 102 102 end; 103 103 … … 200 200 { TGColorManager } 201 201 202 function TGColorManager.GetFormat(Index: Integer): TGColorFormat Class;203 begin 204 Result := TGColorFormat Class(FFormats[Index])202 function TGColorManager.GetFormat(Index: Integer): TGColorFormat; 203 begin 204 Result := TGColorFormat(FFormats[Index]) 205 205 end; 206 206 … … 208 208 begin 209 209 FFormats := TObjectList.Create; 210 FFormats.OwnsObjects := False;211 210 end; 212 211 … … 219 218 procedure TGColorManager.RegisterFormat(Format: TGColorFormatClass); 220 219 begin 221 FFormats.Add( TObject(Format));220 FFormats.Add(Format.Create); 222 221 end; 223 222 … … 281 280 end; 282 281 283 procedure TGColor.SetColorFormat(AValue: TGColorFormatClass); 284 var 285 F: TGColorFormat; 282 procedure TGColor.SetColorFormat(AValue: TGColorFormat); 286 283 begin 287 284 if FColorFormat = AValue then Exit; 288 285 FColorFormat := AValue; 289 F := FColorFormat.Create; 290 ReAllocMem(FData, F.GetPixelSize); 291 F.Free; 286 ReAllocMem(FData, FColorFormat.GetPixelSize); 292 287 end; 293 288 294 289 procedure TGColor.LoadData(BitmapData: Pointer); 295 var 296 F: TGColorFormat; 297 begin 298 F := FColorFormat.Create; 299 Move(BitmapData^, FData^, F.GetPixelSize); 300 F.Free; 290 begin 291 Move(BitmapData^, FData^, FColorFormat.GetPixelSize); 301 292 end; 302 293 303 294 procedure TGColor.SaveData(BitmapData: Pointer); 304 var 305 F: TGColorFormat; 306 begin 307 F := FColorFormat.Create; 308 Move(FData^, BitmapData^, F.GetPixelSize); 309 F.Free; 295 begin 296 Move(FData^, BitmapData^, FColorFormat.GetPixelSize); 310 297 end; 311 298 312 299 function TGColor.ToTColor: TColor; 313 var 314 F: TGColorFormat; 315 begin 316 F := FColorFormat.Create; 317 Result := F.ColorToTColor(Self); 318 F.Free; 300 begin 301 Result := FColorFormat.ColorToTColor(Self); 319 302 end; 320 303 321 304 procedure TGColor.FromTColor(Color: TColor); 322 var 323 F: TGColorFormat; 324 begin 325 F := FColorFormat.Create; 326 F.ColorFromTColor(Self, Color); 327 F.Free; 305 begin 306 FColorFormat.ColorFromTColor(Self, Color); 328 307 end; 329 308 … … 334 313 constructor TGColor.Create; 335 314 begin 336 Format := TGColorFormat ;315 Format := TGColorFormat.Create; 337 316 end; 338 317 … … 357 336 end; 358 337 359 procedure TGBitmap.SetColorFormat(AValue: TGColorFormat Class);338 procedure TGBitmap.SetColorFormat(AValue: TGColorFormat); 360 339 begin 361 340 if FColorFormat = AValue then Exit; … … 378 357 379 358 function TGBitmap.GetPixelDataPos(X, Y: Integer): Pointer; 380 var 381 F: TGColorFormat; 382 begin 383 F := FColorFormat.Create; 384 Result := FData + X * F.GetPixelSize + Y * F.GetPixelSize * FSize.X; 385 F.Free; 359 begin 360 Result := FData + X * FColorFormat.GetPixelSize + Y * FColorFormat.GetPixelSize * FSize.X; 386 361 end; 387 362 388 363 function TGBitmap.GetDataSize: Integer; 389 var 390 F: TGColorFormat; 391 begin 392 F := FColorFormat.Create; 393 Result := Size.X * Size.Y * F.GetPixelSize; 394 F.Free; 364 begin 365 Result := Size.X * Size.Y * FColorFormat.GetPixelSize; 395 366 end; 396 367 … … 471 442 FData := GetMem(0); 472 443 FBackgroundColor := TGColor.Create; 473 ColorFormat := TGColorFormat ;444 ColorFormat := TGColorFormat.Create; 474 445 FBackgroundColor.Format := ColorFormat; 475 446 FBackgroundColor.FromTColor(clBlack);
Note:
See TracChangeset
for help on using the changeset viewer.