Code Monkey home page Code Monkey logo

delafits's Introduction

DeLaFits

DeLaFits is a Delphi and Lazarus library for operations with data in Flexible Image Transport System format.

  • building
  • reading
  • editing
  • rendering

Uses a regions for data access and creation of a graphic image of data.
Supports only Single Image - one header and one data unit.

How to use

Just copy and add Source directory in your project.

  • DeLaFitsCommon.pas - common constants and simple functions
  • DeLaFitsClasses.pas - access to header and data - building, reading, editing
  • DeLaFitsGraphics.pas - rendering of the data - creation of a graphic image

For details, see User's Guide.

Class Hierarchy

class-hierarchy.png

Code Sample

var
  Fit: TFitsFileBitmap;
  I, X, Y: Integer;
  Item: TLineItem;
  Rgn: TRgn;
  Data: array of array of Integer;
  Bmp: TBitmap;
begin
  Fit := TFitsFileBitmap.CreateJoin('some.fit', cFileReadWrite);
  Data := nil;
  Bmp := nil;
  try
    // edit header
    I := Fit.LineBuilder.IndexOf('DATE-OBS');
    if I >= 0 then
    begin
      Fit.LineBuilder.ValuesDateTime[I] := Now;
      Fit.LineBuilder.Notes[I] := 'Set datetime';
    end
    else
    begin
      Item.Keyword       := 'DATE-OBS';
      Item.ValueIndicate := True;
      Item.Value.Dtm     := Now;
      Item.NoteIndicate  := True;
      Item.Note          := 'Add datetime';  
      Fit.LineBuilder.Add(Item, cCastDateTime);
    end;   
    // edit data
    Rgn.X1        := 0;
    Rgn.Y1        := 0;
    Rgn.ColsCount := 200;
    Rgn.RowsCount := 200;
    Fit.DataRep := rep32c;
    Fit.DataPrepare(Pointer(Data), Rgn);
    Fit.DataRead(Pointer(Data), Rgn); 
    for Y := 0 to Rgn.RowsCount - 1 do
    for X := 0 to Rgn.ColsCount - 1 do
      Data[X, Y] := Data[X, Y] + 1; 
    Fit.DataWrite(Pointer(Data), Rgn);    
    // render
    Bmp := TBitmap.Create;
    Rgn.X1     := 0;
    Rgn.Y1     := 0;
    Rgn.Width  := 200;
    Rgn.Height := 200;
    Fit.GraphicColor.ToneContrast := 1.2;
    Fit.GraphicGeom.Scl(2.0, 2.0, xy00).Rot(45.0, xy00);
    Fit.BitmapRead(Bmp, Rgn);
    Bmp.SaveToFile('some.bmp');    
  finally
    Fit.Free;
    if Assigned(Bmp) then
      Bmp.Free;
    Data := nil;
  end;
end;

Credits

DeLaFits is used in the CoLiTec project (software for automated asteroids and comets discoveries).

License

MIT © 2013-2016, Evgeniy Dikov <[email protected]>

delafits's People

Contributors

felleroff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.