Домой Классы Статические функции Перечисления (ENUM) Записи (RECORD)

{Gif|_animated_image}


CLASS {Gif|_animated_image} , UNTESTED, BYTES, BITWISE:



IMPORT : {Bitmap} , {AL4_drawing} , {File_stream} , {Bitmap_direct} , {Canvas} .

STR Path|_file


INDEXING {gif_frame}

INT Frame|_current , READ


BOOL Corrupted , READ


          

ENUMERATION {gif_code|_from} :

        'GIF_BOTH|_NATIVE_AND_AL4' ,

        'GIF_NATIVE|_ONLY' ,

        'GIF_AL4|_ONLY' .



FUN Gif_code|_from ==> {gif_code}



FUN Set_gif_code|_from ( {gif_code} Value|_to_set )



FUNCTION Load|_animated_gif ( STR Path|_of_file ) ==> {Gif} , NEW



FUNCTION From_stream|_animated_gif (
     
{Stream} S|ource_stream ) ==> {Gif} , NEW



METHOD Count|_frames ==> INT



METHOD Set_frame ( INT N|umber_of_frame_0_to_Count_minus_1 )



METHOD Duration|_of_frame|_milliseconds ==> INT



METHOD Width|_entire_gif ==> INT



METHOD Height|_entire_gif ==> INT



-------------------------------------------------------- 'load using {LZW}'

  

STRUCTURE {gif_frame}

      INT Index|_of_frame INDEXING {gif_frame}

      BOOL Corrupt|ed

      {Bitmap} Bitmap_|may_be_smaller_then_entire_size_

      {Geometry}.{point} Top_left|_position_of_frame_on_gif_image

      {extensions} Extensions|_list

      INT Delay|_frame

      {disposal} Disposal_method

      INT Transp_color||Transparent_color|_value|_RGB

      INT Transp_i|ndex||Transparent_color_index INDEXING {color_item}

      BOOL Transparent

      BOOL Really_transp|arent

      BOOL Interlaced

      BOOL Local_colors

      {Memory_stream} Data_|image_

      INT Size_w|idth

      INT Size_h|eight

      BYTE Packed_f|ields

      {color_item} Color_map[] .



ENUMERATION {disposal|_method} :

        'UNDEFINED' ,

        'LEAVE|_INTACT' ,

        'RESTORE_BACK|GROUND' ,

        'RESTORE_PREV|IOUS' .



-------------------------------------------------------------- 'load frame'

   

CONSTANT INT :

          BUFFER_SIZE = 1024 .


CONSTANT INT {image_descriptor_flags} :

          ID_LOCAL_COLOR_TABLE = 0x80

          ID_INTERLACED = 0x40

          ID_SORT|ED_COLORS = 0x20

          ID_RESERVED = 0x0C

          ID_COLOR_TABLE_SIZE = 0x07 .


CONSTANT INT :

          GCE_TRANSPARENT = 1

          GCE_USER_INPUT = 2

          GCE_DISPOSAL_METHOD = 0x1C

          GCE_RESERVED = 0xE0 .



------------------------------------------------------- 'screen descriptor'

STR Version|_GIF87a_GIF89a


{screen_descriptor} Scr|een_descriptor , READ


INT Bits_per_pixel , READ


INT Color_res|_bits , READ


  

CONSTANT INT {logical_screen_descriptor_masks} :

          LSD_GLOBAL_COLOR_TABLE|_SET_IF_GLOBAL_COLOR_TABLE_FOLLOWS_LSD = 0x80

          LSD_COLOR_RESOLUTION = 0x70

          LSD_SORT|ED_GLOBAL_COLOR_TABLE = 8

          LSD_COLOR_TABLE_SIZE|_3LOW_BITS = 7 .



STRUCTURE {screen_descriptor}

      INT W|idth|_scr|een

      INT H|eight|_scr|een

      INT Packed_f|ields

      INT Back_index||Background_color INDEXING {color_item}

      INT Aspect_r|atio .



-------------------------------------------------------- 'global color map'

 

STRUCTURE {color_item}

      BYTE R|ed_component

      BYTE G|reen_component

      BYTE B|lue_component .


{color_item} Color_map[] , READ


INT Back_color||Background|_color



-------------------------------------------------------------- 'extensions'

STR Sep|arator_char_last


BOOL Looping|_defined


INT Repeat_count


      

CONSTANT INT :

          MAX_LOOP_COUNT = 30_000 .


CONSTANT STR :

          CHR_EXT_INTRO|DUCER = "!"

          CHR_IMAGE_SEP|ARATOR = ","

          CHR_TRAILER = ";" .



STRUCTURE {extensions|_list}

      {extension} E|xtension_items[] .



ENUMERATION {extension_type} :

        'UNKNOWN|_EXTENSION' ,

        'GRAPHIC|_EXTENSION' ,

        'PLAIN_TEXT' ,

        'APPLICATION' ,

        'COMMENT' .


CONSTANT INT :

          EXT_LABEL_GRAPHIC = 0xF9

          EXT_LABEL_PLAIN_T|EXT = 1

          EXT_LABEL_APP|LICATION = 0xFF

          EXT_LABEL_COMMENT = 0xFE .



STRUCTURE {extension}

      {extension_type} Type|_of_extension

      STR Lines|_list[]

      INT Loop_count|s|_in_lines[]

      BYTE Block_size|_4_12_11

      BYTE Packed_f|ields

      INT Delay_time|_centiseconds

      INT Transp_index||Transparent_color_index

      BYTE Terminator

      INT Left|_position

      INT Top|_position

      INT Width|_size

      INT Height|_size

      INT Cell_w|idth

      INT Cell_h|eight

      INT Fore_i||Foreground_color_index

      INT Back_i||Background_color_index

      BYTE App_id|entifier_8_bytes[]

      BYTE Authent|ication_3_bytes[] .



---------------------------------------------------------- 'getting bitmap'

    

METHOD Bitmap|_current_frame ==> {Bitmap}


CONSTANT INT :

          OPAQUE|_ALPHA = 0xFF

          TRANSPARENT = 0 .



FUNCTION Can_load ==> BOOL



FUNCTION Can_save ==> BOOL



-------------------------------------------------------------------- 'save'

  

FUNCTION To_file|_by_path (
     
{Bitmap} B|itmap_to_convert_to_gif_and_save ,
     
STR Path|_of_file ) ==> BOOL



FUNCTION To_stream (
     
{Bitmap} B|itmap_to_convert_to_gif_and_save ,
     
{Stream} S|tream_destination ) ==> BOOL


END


См. так же с защищёнными членами