Subversion Repositories Kolibri OS

Rev

Rev 1569 | Rev 1921 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1569 Rev 1593
Line 501... Line 501...
501
    jnz @b
501
    jnz @b
Line 502... Line 502...
502
 
502
 
503
    @@:
503
    @@:
Line -... Line 504...
-
 
504
    ret
-
 
505
 
-
 
506
align 16
-
 
507
.bpp1:
-
 
508
    push ebx edx
-
 
509
    mov ebx, esi
-
 
510
    mov esi, [ebx + Image.Data]
-
 
511
    mov ecx, [ebx + Image.Height]
-
 
512
  .bpp1.pre:
-
 
513
    mov edx, [ebx + Image.Width]
-
 
514
    mov eax, 7
-
 
515
  .bpp1.begin:
-
 
516
    push ecx esi
-
 
517
    xor cx, cx
-
 
518
    bt [esi], eax
-
 
519
    setc cl
-
 
520
    mov esi, [ebx + Image.Palette]
-
 
521
     jcxz @f
-
 
522
    add esi, 4
-
 
523
  @@:
-
 
524
    mov ecx, 3
-
 
525
    cld
-
 
526
    rep movsb
-
 
527
    pop esi ecx
-
 
528
    dec edx
-
 
529
     jz .bpp1.end_line
-
 
530
    dec eax
-
 
531
     jns .bpp1.begin
-
 
532
    mov eax, 7
-
 
533
    inc esi
-
 
534
     jmp .bpp1.begin
-
 
535
 
-
 
536
  .bpp1.end_line:
-
 
537
    dec ecx
-
 
538
     jz .bpp1.quit
-
 
539
    inc esi
-
 
540
     jmp .bpp1.pre
-
 
541
 
-
 
542
  .bpp1.quit:
-
 
543
    pop edx ebx
504
    ret
544
    ret
Line 505... Line 545...
505
 
545
 
506
endp
546
endp
507
 
547
 
Line 889... Line 929...
889
    pop edi esi ecx
929
    pop edi esi ecx
890
    add esi, [scanline_len]
930
    add esi, [scanline_len]
891
    add edi, [scanline_len]
931
    add edi, [scanline_len]
892
    dec ecx
932
    dec ecx
893
    jnz .next_line_horz24
933
    jnz .next_line_horz24
-
 
934
    jmp .exit
-
 
935
 
-
 
936
.bpp1_horz:
-
 
937
    push eax edx
-
 
938
    mov edi, [scanline_len]
-
 
939
    mov edx, [ebx+Image.Width]
-
 
940
    and edx,  0x07
-
 
941
    neg dl
-
 
942
    add dl, 8
-
 
943
    and dl, 0x07                                        ; clear if cl=8
-
 
944
.bpp1_horz.begin:
-
 
945
    push ebx ecx edx esi
-
 
946
    mov eax, 7
-
 
947
    add edi, esi
-
 
948
    sub edi, 1
-
 
949
    mov ebx, [ebx+Image.Width]
-
 
950
    shr ebx, 1
-
 
951
.bpp1_horz.flip_line:
-
 
952
    xor ecx, ecx
-
 
953
    bt  [esi], eax
-
 
954
    setc cl
-
 
955
    bt  [edi], edx
-
 
956
     jc .bpp1_horz.one
-
 
957
  .bpp1_horz.zero:
-
 
958
    btr [esi], eax
-
 
959
     jmp @f
-
 
960
  .bpp1_horz.one:
-
 
961
    bts [esi], eax
-
 
962
  @@:
-
 
963
     jecxz .bpp1_horz.reset
-
 
964
  .bpp1_horz.set:
-
 
965
    bts [edi], edx
-
 
966
     jmp @f
-
 
967
  .bpp1_horz.reset:
-
 
968
    btr [edi], edx
-
 
969
  @@:
-
 
970
    inc edx
-
 
971
    and edx, 0x07
-
 
972
     jnz @f
-
 
973
    dec edi
-
 
974
  @@:
-
 
975
    dec eax
-
 
976
     jns @f
-
 
977
    mov eax, 7
-
 
978
    inc esi
-
 
979
  @@:
-
 
980
    dec ebx
-
 
981
     jnz .bpp1_horz.flip_line
-
 
982
 
-
 
983
    pop esi edx ecx ebx
-
 
984
    add esi, [scanline_len]
-
 
985
    mov edi, [scanline_len]
-
 
986
    dec ecx
-
 
987
     jnz .bpp1_horz.begin
-
 
988
    pop edx eax
Line 894... Line 989...
894
 
989
 
895
  .exit:
990
  .exit:
896
    xor eax, eax
991
    xor eax, eax
897
    inc eax
992
    inc eax
Line 988... Line 1083...
988
    mov eax, [scanline_len_new]
1083
    mov eax, [scanline_len_new]
989
    imul    eax, ecx
1084
    imul    eax, ecx
990
    add eax, [ebx + Image.Data]
1085
    add eax, [ebx + Image.Data]
991
    mov [pixels_ptr], eax
1086
    mov [pixels_ptr], eax
Line -... Line 1087...
-
 
1087
 
-
 
1088
    cmp [ebx + Image.Type], Image.bpp1
992
 
1089
    jz  .rotate_ccw1
993
    cmp [ebx + Image.Type], Image.bpp8
1090
    cmp [ebx + Image.Type], Image.bpp8
994
    jz  .rotate_ccw8
1091
    jz  .rotate_ccw8
995
    cmp [ebx + Image.Type], Image.bpp24
1092
    cmp [ebx + Image.Type], Image.bpp24
996
    jz  .rotate_ccw24
1093
    jz  .rotate_ccw24
Line 1180... Line 1277...
1180
    rep movsb
1277
    rep movsb
Line 1181... Line 1278...
1181
 
1278
 
1182
    pop ecx
1279
    pop ecx
Line -... Line 1280...
-
 
1280
    jmp .next_column_ccw_low24
-
 
1281
 
-
 
1282
.rotate_ccw1:
-
 
1283
    push ecx edx
-
 
1284
 
-
 
1285
    mov eax, [ebx+Image.Height]
-
 
1286
    add eax, 7
-
 
1287
    shr eax, 3
-
 
1288
    mul word[ebx+Image.Width]
-
 
1289
    shl eax, 16
-
 
1290
    shrd eax, edx, 16
-
 
1291
    push eax                                            ; save new data size
-
 
1292
 
-
 
1293
    invoke  mem.alloc, eax
-
 
1294
    or  eax, eax
-
 
1295
    jz  .error
-
 
1296
    push eax                                            ; save pointer to new data
-
 
1297
 
-
 
1298
    mov ecx, [ebx+Image.Width]
-
 
1299
    and ecx,  0x07
-
 
1300
    neg cl
-
 
1301
    add cl, 8
-
 
1302
    and cl, 0x07                                        ; clear if cl=8
-
 
1303
 
-
 
1304
    mov esi, eax
-
 
1305
    mov edi, [ebx+Image.Data]
-
 
1306
    mov eax, 7
-
 
1307
    mov edx, [scanline_len_old]
-
 
1308
    dec edx
-
 
1309
    add edi, edx
-
 
1310
 
-
 
1311
  .rotate_ccw1.begin:
-
 
1312
    bt  [edi], ecx
-
 
1313
     jc .rotate_ccw1.one
-
 
1314
  .rotate_ccw1.zero:
-
 
1315
    btr [esi], eax
-
 
1316
     jmp @f
-
 
1317
  .rotate_ccw1.one:
-
 
1318
    bts [esi], eax
-
 
1319
  @@:
-
 
1320
    add edi, [scanline_len_old]
-
 
1321
    dec [scanline_pixels_new]
-
 
1322
     jz .rotate_ccw1.end_of_line
-
 
1323
    dec eax
-
 
1324
     jns .rotate_ccw1.begin
-
 
1325
    mov eax, 7
-
 
1326
    inc esi
-
 
1327
     jmp .rotate_ccw1.begin
-
 
1328
 
-
 
1329
  .rotate_ccw1.end_of_line:
-
 
1330
    inc esi
-
 
1331
    mov eax, 7
-
 
1332
    mov edi, [ebx+Image.Height]
-
 
1333
    mov [scanline_pixels_new],  edi
-
 
1334
    inc ecx
-
 
1335
    and cl, 0x07
-
 
1336
     jz @f
-
 
1337
    mov edi, [ebx+Image.Data]
-
 
1338
    add edi, edx
-
 
1339
     jmp .rotate_ccw1.begin 
-
 
1340
  @@:
-
 
1341
    dec edx
-
 
1342
     js .rotate_ccw1.quit
-
 
1343
    mov edi, [ebx+Image.Data]
-
 
1344
    add edi, edx
-
 
1345
     jmp .rotate_ccw1.begin
-
 
1346
 
-
 
1347
  .rotate_ccw1.quit:
-
 
1348
    pop eax                                             ; get pointer to new data
-
 
1349
    mov esi, eax
-
 
1350
    mov edi, [ebx + Image.Data]
-
 
1351
    pop ecx                                             ; get new data size
-
 
1352
    rep movsb
-
 
1353
 
-
 
1354
    invoke  mem.free, eax
-
 
1355
 
-
 
1356
    pop edx ecx
1183
    jmp .next_column_ccw_low24
1357
     jmp .exchange_dims
1184
 
1358
 
1185
  .rotate_cw_low:
1359
  .rotate_cw_low:
1186
    mov eax, [ebx + Image.Height]
1360
    mov eax, [ebx + Image.Height]
1187
    mov [scanline_pixels_new], eax
1361
    mov [scanline_pixels_new], eax
Line 1201... Line 1375...
1201
    mov eax, [scanline_len_new]
1375
    mov eax, [scanline_len_new]
1202
    imul    eax, ecx
1376
    imul    eax, ecx
1203
    add eax, [ebx + Image.Data]
1377
    add eax, [ebx + Image.Data]
1204
    mov [pixels_ptr], eax
1378
    mov [pixels_ptr], eax
Line -... Line 1379...
-
 
1379
 
-
 
1380
    cmp [ebx + Image.Type], Image.bpp1
1205
 
1381
    jz  .rotate_cw1
1206
    cmp [ebx + Image.Type], Image.bpp8
1382
    cmp [ebx + Image.Type], Image.bpp8
1207
    jz  .rotate_cw8
1383
    jz  .rotate_cw8
1208
    cmp [ebx + Image.Type], Image.bpp24
1384
    cmp [ebx + Image.Type], Image.bpp24
1209
    jz  .rotate_cw24
1385
    jz  .rotate_cw24
Line 1403... Line 1579...
1403
    rep movsb
1579
    rep movsb
Line 1404... Line 1580...
1404
 
1580
 
1405
    pop ecx
1581
    pop ecx
Line -... Line 1582...
-
 
1582
    jmp .next_column_cw_low24
-
 
1583
 
-
 
1584
.rotate_cw1:
-
 
1585
    push ecx edx
-
 
1586
 
-
 
1587
    mov eax, [ebx+Image.Height]
-
 
1588
    add eax, 7
-
 
1589
    shr eax, 3
-
 
1590
    mul word[ebx+Image.Width]
-
 
1591
    shl eax, 16
-
 
1592
    shrd eax, edx, 16
-
 
1593
 
-
 
1594
    push eax                                            ; save new data size
-
 
1595
 
-
 
1596
    invoke  mem.alloc, eax
-
 
1597
    or  eax, eax
-
 
1598
    jz  .error
-
 
1599
    push eax                                            ; save pointer to new data
-
 
1600
 
-
 
1601
    mov ecx, 7
-
 
1602
 
-
 
1603
    mov edx, [ebx+Image.Width]
-
 
1604
    mov [pixels_ptr],   edx                             ; we don't use pixels_ptr as it do other procedures, we save there [ebx+Image.Width]
-
 
1605
    mov esi, eax
-
 
1606
    mov edi, [ebx+Image.Data]
-
 
1607
    mov eax, [ebx+Image.Height]
-
 
1608
    dec eax
-
 
1609
    mul [scanline_len_old]
-
 
1610
    add edi, eax
-
 
1611
    mov eax, 7
-
 
1612
    mov edx, 0
-
 
1613
 
-
 
1614
  .rotate_cw1.begin:
-
 
1615
    bt  [edi], ecx
-
 
1616
     jc .rotate_cw1.one
-
 
1617
  .rotate_cw1.zero:
-
 
1618
    btr [esi], eax
-
 
1619
     jmp @f
-
 
1620
  .rotate_cw1.one:
-
 
1621
    bts [esi], eax
-
 
1622
  @@:
-
 
1623
    sub edi, [scanline_len_old]
-
 
1624
    dec [scanline_pixels_new]
-
 
1625
     jz .rotate_cw1.end_of_line
-
 
1626
    dec eax
-
 
1627
     jns .rotate_cw1.begin
-
 
1628
    mov eax, 7
-
 
1629
    inc esi
-
 
1630
     jmp .rotate_cw1.begin
-
 
1631
 
-
 
1632
  .rotate_cw1.end_of_line:
-
 
1633
    dec [pixels_ptr]
-
 
1634
     jz .rotate_cw1.quit
-
 
1635
    inc esi
-
 
1636
    mov eax, [ebx+Image.Height]
-
 
1637
    mov [scanline_pixels_new],   eax
-
 
1638
    mov eax, 7
-
 
1639
    dec ecx
-
 
1640
     js @f
-
 
1641
    mov edi, [ebx+Image.Height]
-
 
1642
    dec edi
-
 
1643
    imul edi, [scanline_len_old]
-
 
1644
    add edi, [ebx+Image.Data]
-
 
1645
    add edi, edx
-
 
1646
     jmp .rotate_cw1.begin
-
 
1647
  @@:
-
 
1648
    mov ecx, 7
-
 
1649
    inc edx
-
 
1650
    cmp edx, [scanline_len_old]
-
 
1651
     je .rotate_cw1.quit
-
 
1652
    mov edi, [ebx+Image.Height]
-
 
1653
    dec edi
-
 
1654
    imul edi, [scanline_len_old]
-
 
1655
    add edi, [ebx+Image.Data]
-
 
1656
    add edi, edx
-
 
1657
     jmp .rotate_cw1.begin
-
 
1658
 
-
 
1659
  .rotate_cw1.quit:
-
 
1660
    pop eax                                             ; get pointer to new data
-
 
1661
    mov esi, eax
-
 
1662
    mov edi, [ebx + Image.Data]
-
 
1663
    pop ecx                                             ; get new data size
-
 
1664
    rep movsb
-
 
1665
 
-
 
1666
    invoke  mem.free, eax
-
 
1667
 
-
 
1668
    pop edx ecx
1406
    jmp .next_column_cw_low24
1669
     jmp .exchange_dims
1407
 
1670
 
Line 1408... Line 1671...
1408
  .flip:
1671
  .flip:
1409
    jmp .exit
1672
    jmp .exit
Line 1611... Line 1874...
1611
    test    eax, eax
1874
    test    eax, eax
1612
    jz  .error
1875
    jz  .error
1613
; do not allow images which require too many memory
1876
; do not allow images which require too many memory
1614
    cmp eax, 4000000h
1877
    cmp eax, 4000000h
1615
    jae .error
1878
    jae .error
-
 
1879
    cmp [ebx + Image.Type], Image.bpp1
-
 
1880
    jz  .bpp1
1616
    cmp [ebx + Image.Type], Image.bpp8
1881
    cmp [ebx + Image.Type], Image.bpp8
1617
    jz  .bpp8
1882
    jz  .bpp8
1618
    cmp [ebx + Image.Type], Image.bpp24
1883
    cmp [ebx + Image.Type], Image.bpp24
1619
    jz  .bpp24
1884
    jz  .bpp24
1620
.bpp32:
1885
.bpp32:
Line 1623... Line 1888...
1623
.bpp24:
1888
.bpp24:
1624
    lea eax, [eax*3]
1889
    lea eax, [eax*3]
1625
    jmp @f
1890
    jmp @f
1626
.bpp8:
1891
.bpp8:
1627
    add eax, 256*4  ; for palette
1892
    add eax, 256*4  ; for palette
-
 
1893
    jmp @f
-
 
1894
.bpp1:
-
 
1895
    mov eax, [_width]
-
 
1896
    add eax, 7
-
 
1897
    shr eax, 3
-
 
1898
    mul word[_height]
-
 
1899
    shl eax, 16
-
 
1900
    mov ax,  dx
-
 
1901
    ror eax, 16
-
 
1902
 
-
 
1903
    push ebx
-
 
1904
    mov ebx, eax
-
 
1905
 
-
 
1906
    mov eax, [_height]
-
 
1907
    add eax, 7
-
 
1908
    shr eax, 3
-
 
1909
    mul word[_width]
-
 
1910
    shl eax, 16
-
 
1911
    mov ax,  dx
-
 
1912
    ror eax, 16
-
 
1913
 
-
 
1914
    cmp eax, ebx
-
 
1915
     jge .bpp1.skip
-
 
1916
    mov eax, ebx
-
 
1917
  .bpp1.skip:
-
 
1918
    pop ebx
-
 
1919
 
-
 
1920
    add eax, 2*4    ; for palette
1628
@@:
1921
@@:
1629
    mov esi, eax
1922
    mov esi, eax
1630
    invoke  mem.realloc, [ebx + Image.Data], eax
1923
    invoke  mem.realloc, [ebx + Image.Data], eax
1631
    or  eax, eax
1924
    or  eax, eax
1632
    jz  .error
1925
    jz  .error
Line 1635... Line 1928...
1635
    push    [_width]
1928
    push    [_width]
1636
    pop [ebx + Image.Width]
1929
    pop [ebx + Image.Width]
1637
    push    [_height]
1930
    push    [_height]
1638
    pop [ebx + Image.Height]
1931
    pop [ebx + Image.Height]
1639
    cmp [ebx + Image.Type], Image.bpp8
1932
    cmp [ebx + Image.Type], Image.bpp8
1640
    jnz .ret
1933
    jnz @f
1641
    lea esi, [eax + esi - 256*4]
1934
    lea esi, [eax + esi - 256*4]
1642
    mov [ebx + Image.Palette], esi
1935
    mov [ebx + Image.Palette], esi
1643
    jmp .ret
1936
    jmp .ret
-
 
1937
@@:
-
 
1938
    cmp [ebx + Image.Type], Image.bpp1
-
 
1939
    jnz .ret
-
 
1940
    lea esi, [eax + esi - 2*4]
-
 
1941
    mov [ebx + Image.Palette], esi
-
 
1942
    jmp .ret
Line 1644... Line 1943...
1644
 
1943
 
1645
  .error:
1944
  .error:
1646
    xor eax, eax
1945
    xor eax, eax
1647
  .ret:
1946
  .ret:
Line 1656... Line 1955...
1656
;;------------------------------------------------------------------------------------------------;;
1955
;;------------------------------------------------------------------------------------------------;;
1657
;> --- TBD ---                                                                                    ;;
1956
;> --- TBD ---                                                                                    ;;
1658
;;------------------------------------------------------------------------------------------------;;
1957
;;------------------------------------------------------------------------------------------------;;
1659
;< --- TBD ---                                                                                    ;;
1958
;< --- TBD ---                                                                                    ;;
1660
;;================================================================================================;;
1959
;;================================================================================================;;
-
 
1960
    cmp [ebx + Image.Type], Image.bpp1
-
 
1961
    jz  .bpp1.1
1661
    cmp [ebx + Image.Type], Image.bpp8
1962
    cmp [ebx + Image.Type], Image.bpp8
1662
    jz  .bpp8.1
1963
    jz  .bpp8.1
1663
    cmp [ebx + Image.Type], Image.bpp24
1964
    cmp [ebx + Image.Type], Image.bpp24
1664
    jz  .bpp24.1
1965
    jz  .bpp24.1
1665
    add eax, eax
1966
    add eax, eax
1666
    cmp [ebx + Image.Type], Image.bpp32
1967
    cmp [ebx + Image.Type], Image.bpp32
1667
    jnz @f
1968
    jnz .quit
1668
    add eax, eax
1969
    add eax, eax
1669
    jmp @f
1970
    jmp .quit
1670
.bpp24.1:
1971
.bpp24.1:
1671
    lea eax, [eax*3]
1972
    lea eax, [eax*3]
-
 
1973
    jmp .quit
-
 
1974
.bpp1.1:
-
 
1975
    add eax, 7
-
 
1976
    shr eax, 3
1672
.bpp8.1:
1977
.bpp8.1:
1673
@@:
1978
.quit:
1674
    ret
1979
    ret
Line 1675... Line 1980...
1675
 
1980
 
1676
 
1981
 
Line 1695... Line 2000...
1695
  .z80 dd img.is.z80, img.decode.z80, img.encode.z80 ;this must be the last entry as there are no
2000
  .z80 dd img.is.z80, img.decode.z80, img.encode.z80 ;this must be the last entry as there are no
1696
  ;signatures in z80 screens at all
2001
  ;signatures in z80 screens at all
1697
       dd 0
2002
       dd 0
Line 1698... Line 2003...
1698
 
2003
 
1699
align 4
2004
align 4
1700
type2bpp    dd  8, 24, 32, 15, 16
2005
type2bpp    dd  8, 24, 32, 15, 16, 1
1701
img._.do_rgb.handlers:
2006
img._.do_rgb.handlers:
1702
    dd  img._.do_rgb.bpp8
2007
    dd  img._.do_rgb.bpp8
1703
    dd  img._.do_rgb.bpp24
2008
    dd  img._.do_rgb.bpp24
1704
    dd  img._.do_rgb.bpp32
2009
    dd  img._.do_rgb.bpp32
1705
    dd  img._.do_rgb.bpp15.amd  ; can be overwritten in lib_init
2010
    dd  img._.do_rgb.bpp15.amd  ; can be overwritten in lib_init
-
 
2011
    dd  img._.do_rgb.bpp16.amd  ; can be overwritten in lib_init
Line 1706... Line 2012...
1706
    dd  img._.do_rgb.bpp16.amd  ; can be overwritten in lib_init
2012
    dd  img._.do_rgb.bpp1
1707
 
2013
 
1708
img.flip.layer.handlers_horz:
2014
img.flip.layer.handlers_horz:
1709
    dd  img.flip.layer.bpp8_horz
2015
    dd  img.flip.layer.bpp8_horz
1710
    dd  img.flip.layer.bpp24_horz
2016
    dd  img.flip.layer.bpp24_horz
1711
    dd  img.flip.layer.bpp32_horz
2017
    dd  img.flip.layer.bpp32_horz
-
 
2018
    dd  img.flip.layer.bpp1x_horz
Line 1712... Line 2019...
1712
    dd  img.flip.layer.bpp1x_horz
2019
    dd  img.flip.layer.bpp1x_horz
1713
    dd  img.flip.layer.bpp1x_horz
2020
    dd  img.flip.layer.bpp1_horz
1714
 
2021
 
1715
;;================================================================================================;;
2022
;;================================================================================================;;