1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
|
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>nevrax.org : docs</TITLE>
<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF='/'><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF='/'><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>
<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!------ Begin Box ------>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
<TABLE cellspacing=0 cellpadding=1 border=0>
<tr><td ALIGN=middle><a class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
</TABLE>
</TD></TR></TABLE></TD></TR></TABLE>
<!------ End Box ------>
</TD>
<TD WIDTH=15><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD ALIGN=left valign=top><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!-- title -->
<TABLE background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
<!-- block -->
<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
<TD><B>Documentation</B></TD>
<TD ALIGN=RIGHT> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>bitmap.cpp</h1><a href="bitmap_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00009 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
00010 <font class="comment"> *</font>
00011 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00012 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00013 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00014 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00015 <font class="comment"> * any later version.</font>
00016 <font class="comment"></font>
00017 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00018 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00019 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00020 <font class="comment"> * General Public License for more details.</font>
00021 <font class="comment"></font>
00022 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00023 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00024 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00025 <font class="comment"> * MA 02111-1307, USA.</font>
00026 <font class="comment"> */</font>
00027
00028 <font class="preprocessor">#include "<a class="code" href="stdmisc_8h.html">stdmisc.h</a>"</font>
00029
00030 <font class="preprocessor">#include <memory></font>
00031 <font class="preprocessor">#include <algorithm></font>
00032
00033 <font class="comment">/*extern "C"</font>
00034 <font class="comment">{</font>
00035 <font class="comment">#include <jpeglib.h></font>
00036 <font class="comment">}</font>
00037 <font class="comment">*/</font>
00038
00039 <font class="preprocessor">#include "<a class="code" href="bitmap_8h.html">nel/misc/bitmap.h</a>"</font>
00040 <font class="preprocessor">#include "<a class="code" href="stream_8h.html">nel/misc/stream.h</a>"</font>
00041 <font class="preprocessor">#include "<a class="code" href="file_8h.html">nel/misc/file.h</a>"</font>
00042
00043
00044 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00045
00046 <font class="keyword">namespace </font>NLMISC
00047 {
00048
00049
<a name="l00050"></a><a class="code" href="structNLMISC_1_1EDDSBadHeader.html">00050</a> <font class="keyword">struct </font>EDDSBadHeader : <font class="keyword">public</font> NLMISC::EStream
00051 {
<a name="l00052"></a><a class="code" href="structNLMISC_1_1EDDSBadHeader.html#a0">00052</a> <a class="code" href="structNLMISC_1_1EDDSBadHeader.html#a0">EDDSBadHeader</a>() : <a class="code" href="structNLMISC_1_1EStream.html#a0">EStream</a>( "Bad or unrecognized <a class="code" href="namespaceNLMISC.html#a2">DDS</a> <a class="code" href="cf__lexical_8cpp.html#a95">file</a> header" ) {}
00053 };
00054
<a name="l00055"></a><a class="code" href="structNLMISC_1_1ESeekFailed.html">00055</a> <font class="keyword">struct </font>ESeekFailed : <font class="keyword">public</font> NLMISC::EStream
00056 {
<a name="l00057"></a><a class="code" href="structNLMISC_1_1ESeekFailed.html#a0">00057</a> <a class="code" href="structNLMISC_1_1ESeekFailed.html#a0">ESeekFailed</a>() : <a class="code" href="structNLMISC_1_1EStream.html#a0">EStream</a>( "Seek failed" ) {}
00058 };
00059
<a name="l00060"></a><a class="code" href="structNLMISC_1_1EAllocationFailure.html">00060</a> <font class="keyword">struct </font>EAllocationFailure : <font class="keyword">public</font> Exception
00061 {
<a name="l00062"></a><a class="code" href="structNLMISC_1_1EAllocationFailure.html#a0">00062</a> <a class="code" href="structNLMISC_1_1EAllocationFailure.html#a0">EAllocationFailure</a>() : <a class="code" href="classNLMISC_1_1Exception.html#a0">Exception</a>( "Can'<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a> allocate memory" ) {}
00063 };
00064
00065 <font class="keywordtype">void</font> <a class="code" href="namespaceNLMISC.html#a285">blendFromui</a>(<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> &c0, <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> &c1, uint coef);
00066 uint32 <a class="code" href="namespaceNLMISC.html#a286">blend</a>(uint32 &n0, uint32 &n1, uint32 coef0);
00067
<a name="l00068"></a><a class="code" href="classNLMISC_1_1CBitmap.html#p0">00068</a> <font class="keyword">const</font> uint32 CBitmap::bitPerPixels[ModeCount]=
00069 {
00070 32, <font class="comment">// RGBA</font>
00071 8, <font class="comment">// Luminance</font>
00072 8, <font class="comment">// Alpha</font>
00073 16, <font class="comment">// AlphaLuminance</font>
00074 4, <font class="comment">// DXTC1</font>
00075 4, <font class="comment">// DXTC1Alpha</font>
00076 8, <font class="comment">// DXTC3</font>
00077 8, <font class="comment">// DXTC5</font>
00078 16 <font class="comment">// DsDt</font>
00079 };
00080
<a name="l00081"></a><a class="code" href="classNLMISC_1_1CBitmap.html#p1">00081</a> <font class="keyword">const</font> uint32 CBitmap::DXTC1HEADER = <a class="code" href="bitmap_8h.html#a0">NL_MAKEFOURCC</a>(<font class="charliteral">'D'</font>,<font class="charliteral">'X'</font>, <font class="charliteral">'T'</font>, <font class="charliteral">'1'</font>);
<a name="l00082"></a><a class="code" href="classNLMISC_1_1CBitmap.html#p2">00082</a> <font class="keyword">const</font> uint32 CBitmap::DXTC3HEADER = <a class="code" href="bitmap_8h.html#a0">NL_MAKEFOURCC</a>(<font class="charliteral">'D'</font>,<font class="charliteral">'X'</font>, <font class="charliteral">'T'</font>, <font class="charliteral">'3'</font>);
<a name="l00083"></a><a class="code" href="classNLMISC_1_1CBitmap.html#p3">00083</a> <font class="keyword">const</font> uint32 CBitmap::DXTC5HEADER = <a class="code" href="bitmap_8h.html#a0">NL_MAKEFOURCC</a>(<font class="charliteral">'D'</font>,<font class="charliteral">'X'</font>, <font class="charliteral">'T'</font>, <font class="charliteral">'5'</font>);
00084
00085 <font class="comment">// static data for jpeg compression (used by writeJPG())</font>
00086 <a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> *<a class="code" href="namespaceNLMISC.html#a185">JPGStream</a> = NULL;
00087 <font class="keyword">const</font> uint32 <a class="code" href="namespaceNLMISC.html#a186">JPGBufferSize</a> = 1000;
00088 <font class="keywordtype">char</font> <a class="code" href="namespaceNLMISC.html#a187">JPGBuffer</a>[<a class="code" href="namespaceNLMISC.html#a186">JPGBufferSize</a>];
00089
00090
00091 <font class="comment">/*-------------------------------------------------------------------*\</font>
00092 <font class="comment"> load </font>
00093 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00094"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a2">00094</a> uint8 CBitmap::load(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f, uint mipMapSkip)
00095 {
00096 <a class="code" href="debug_8h.html#a6">nlassert</a>(f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>());
00097
00098 <font class="comment">// testing if DDS</font>
00099 uint32 fileType = 0;;
00100 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(fileType);
00101 <font class="keywordflow">if</font>(fileType == <a class="code" href="namespaceNLMISC.html#a2">DDS</a>)
00102 {
00103 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#c1">readDDS</a>(f, mipMapSkip);
00104 }
00105 <font class="comment">// assuming it's TGA</font>
00106 <font class="keywordflow">else</font>
00107 {
00108 <a class="code" href="classNLMISC_1_1IStream.html#s3">NLMISC::IStream::TSeekOrigin</a> origin= f.<a class="code" href="classNLMISC_1_1IStream.html#s3s0">begin</a>;
00109 <font class="keywordflow">if</font>(!f.<a class="code" href="classNLMISC_1_1IStream.html#a31">seek</a> (0, origin))
00110 {
00111 <font class="keywordflow">throw</font> ESeekFailed();
00112 }
00113
00114 <font class="comment">// Reading header, </font>
00115 <font class="comment">// To make sure that the bitmap is TGA, we check imageType and imageDepth.</font>
00116 uint8 lengthID;
00117 uint8 cMapType;
00118 uint8 imageType;
00119 uint16 tgaOrigin;
00120 uint16 length;
00121 uint8 <a class="code" href="driver__opengl__extension__def_8h.html#a391">depth</a>;
00122 uint16 xOrg;
00123 uint16 yOrg;
00124 uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;
00125 uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
00126 uint8 imageDepth;
00127 uint8 desc;
00128
00129 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(lengthID);
00130 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(cMapType);
00131 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(imageType);
00132 <font class="keywordflow">if</font>(imageType!=2 && imageType!=3 && imageType!=10 && imageType!=11) <font class="keywordflow">return</font> 0;
00133 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(tgaOrigin);
00134 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(length);
00135 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a391">depth</a>);
00136 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(xOrg);
00137 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(yOrg);
00138 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>);
00139 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>);
00140 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(imageDepth);
00141 <font class="keywordflow">if</font>(imageDepth!=8 && imageDepth!=16 && imageDepth!=24 && imageDepth!=32) <font class="keywordflow">return</font> 0;
00142 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(desc);
00143
00144 <font class="keywordflow">if</font>(!f.<a class="code" href="classNLMISC_1_1IStream.html#a31">seek</a> (0, origin))
00145 {
00146 <font class="keywordflow">throw</font> ESeekFailed();
00147 }
00148 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#c2">readTGA</a>(f);
00149 }
00150 }
00151
00152
00153 <font class="comment">/*-------------------------------------------------------------------*\</font>
00154 <font class="comment"> makeDummy </font>
00155 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00156"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a3">00156</a> <font class="keywordtype">void</font> CBitmap::makeDummy()
00157 {
00158 <font class="keyword">static</font> <font class="keyword">const</font> uint8 bitmap[1024]= {
00159 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00160 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
00161 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00162 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00163 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,
00164 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,
00165 0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,
00166 0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,
00167 0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,
00168 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00169 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00170 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00171 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00172 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00173 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00174 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00175 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00176 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
00177 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00178 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00179 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,
00180 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,
00181 0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,
00182 0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,
00183 0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,
00184 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00185 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00186 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00187 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00188 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00189 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
00190 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00191 };
00192
00193 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>;
00194 <a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a> = 1;
00195 <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>= 32;
00196 <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>= 32;
00197 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].resize(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>*<font class="keyword">sizeof</font>(<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>));
00198 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pix= (<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>*)(&(*<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].begin()));
00199
00200 <font class="keywordflow">for</font>(sint i=0;i<(sint)(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>);i++)
00201 {
00202 <font class="keywordflow">if</font>(bitmap[i])
00203 pix[i].<a class="code" href="classNLMISC_1_1CRGBA.html#a10">set</a>(255,255,255,255);
00204 <font class="keywordflow">else</font>
00205 pix[i].<a class="code" href="classNLMISC_1_1CRGBA.html#a10">set</a>(0,0,0,255);
00206 }
00207
00208 }
00209
00210
00211
00212
00213 <font class="comment">/*-------------------------------------------------------------------*\</font>
00214 <font class="comment"> readDDS </font>
00215 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00216"></a><a class="code" href="classNLMISC_1_1CBitmap.html#c1">00216</a> uint8 CBitmap::readDDS(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f, uint mipMapSkip)
00217 {
00218 <font class="comment">//------------------ Reading Header ------------------------</font>
00219
00220 <font class="comment">//-------------- reading entire header</font>
00221
00222 uint32 size = 0;
00223 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(size); <font class="comment">// size in Bytes of header(without "DDS")</font>
00224 uint32 * _DDSSurfaceDesc = <font class="keyword">new</font> uint32[size];
00225 std::auto_ptr<uint32> _DDSSurfaceDescAuto(_DDSSurfaceDesc);
00226 _DDSSurfaceDesc[0]= size;
00227
00228 <font class="preprocessor">#ifdef NL_LITTLE_ENDIAN</font>
00229 <font class="preprocessor"></font> f.<a class="code" href="classNLMISC_1_1IStream.html#z327_0">serialBuffer</a>((uint8*)(_DDSSurfaceDesc+1), size-4);
00230 <font class="preprocessor">#else</font>
00231 <font class="preprocessor"></font> <font class="keywordflow">for</font>(uint i= 0; i<size/4 - 1; i++)
00232 {
00233 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(_DDSSurfaceDesc[i+1]);
00234 }
00235 <font class="preprocessor">#endif</font>
00236 <font class="preprocessor"></font>
00237 <font class="comment">// flags determines which members of the header structure contain valid data</font>
00238 uint32 flags = _DDSSurfaceDesc[1];
00239
00240 <font class="comment">//verify if file have linearsize set</font>
00241 <font class="keywordflow">if</font>(!(flags & <a class="code" href="bitmap_8h.html#a1">DDSD_LINEARSIZE</a>))
00242 {
00243 <font class="keywordflow">throw</font> EDDSBadHeader();
00244 }
00245
00246 <font class="comment">//-------------- extracting and testing useful info</font>
00247
00248 <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> = _DDSSurfaceDesc[2];
00249 <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a> = _DDSSurfaceDesc[3];
00250 <a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>= (uint8) _DDSSurfaceDesc[6];
00251 <font class="comment">// If no mipmap.</font>
00252 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>==0)
00253 <a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>=1;
00254 <font class="keywordflow">switch</font> (_DDSSurfaceDesc[20])
00255 {
00256 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#p1">DXTC1HEADER</a>:
00257 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>=<a class="code" href="classNLMISC_1_1CBitmap.html#s11s4">DXTC1</a>;
00258 <font class="keywordflow">break</font>;
00259 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#p2">DXTC3HEADER</a>:
00260 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>=<a class="code" href="classNLMISC_1_1CBitmap.html#s11s6">DXTC3</a>;
00261 <font class="keywordflow">break</font>;
00262 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#p3">DXTC5HEADER</a>:
00263 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>=<a class="code" href="classNLMISC_1_1CBitmap.html#s11s7">DXTC5</a>;
00264 <font class="keywordflow">break</font>;
00265 }
00266
00267 flags = _DDSSurfaceDesc[19]; <font class="comment">//PixelFormat flags</font>
00268
00269 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>==<a class="code" href="classNLMISC_1_1CBitmap.html#s11s4">DXTC1</a> && _DDSSurfaceDesc[21]>0) <font class="comment">//AlphaBitDepth</font>
00270 {
00271 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s5">DXTC1Alpha</a>;
00272 }
00273
00274 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>!= <a class="code" href="classNLMISC_1_1CBitmap.html#s11s4">DXTC1</a> && <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>!= <a class="code" href="classNLMISC_1_1CBitmap.html#s11s5">DXTC1Alpha</a> && <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>!= <a class="code" href="classNLMISC_1_1CBitmap.html#s11s6">DXTC3</a> && <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>!= <a class="code" href="classNLMISC_1_1CBitmap.html#s11s7">DXTC5</a>)
00275 {
00276 <font class="keywordflow">throw</font> EDDSBadHeader();
00277 }
00278
00279 <font class="comment">// compute the min power of 2 between width and height</font>
00280 uint minSizeLevel= <a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>, <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>);
00281 minSizeLevel= <a class="code" href="namespaceNLMISC.html#a224">getPowerOf2</a>(minSizeLevel);
00282
00283 <font class="comment">//------------- manage mipMapSkip </font>
00284 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>>1 && mipMapSkip>0 && minSizeLevel>2)
00285 {
00286 <font class="comment">// Keep at least the level where width and height are at leat 4.</font>
00287 mipMapSkip= <a class="code" href="bit__set_8cpp.html#a0">min</a>(mipMapSkip, minSizeLevel-2);
00288 <font class="comment">// skip any mipmap</font>
00289 uint seekSize= 0;
00290 <font class="keywordflow">while</font>(mipMapSkip>0)
00291 {
00292 uint32 mipMapSz;
00293 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>==<a class="code" href="classNLMISC_1_1CBitmap.html#s11s4">DXTC1</a> || <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>==<a class="code" href="classNLMISC_1_1CBitmap.html#s11s5">DXTC1Alpha</a>)
00294 mipMapSz = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>/2;
00295 <font class="keywordflow">else</font>
00296 mipMapSz = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
00297
00298 <font class="comment">// add to how many to skip</font>
00299 seekSize+= mipMapSz;
00300
00301 <font class="comment">// Size of final bitmap is reduced.</font>
00302 <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>>>=1;
00303 <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>>>=1;
00304 <a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>--;
00305 mipMapSkip--;
00306 }
00307 <font class="comment">// skip data in file</font>
00308 <font class="keywordflow">if</font>(seekSize>0)
00309 {
00310 <font class="keywordflow">if</font>(!f.<a class="code" href="classNLMISC_1_1IStream.html#a31">seek</a>(seekSize, IStream::current))
00311 {
00312 <font class="keywordflow">throw</font> ESeekFailed();
00313 }
00314 }
00315
00316 }
00317
00318 <font class="comment">//------------- preload all the mipmaps (one serialBuffer() is faster)</font>
00319 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
00320 uint32 h = <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
00321 uint32 totalSize= 0;
00322
00323 uint8 m;
00324 <font class="keywordflow">for</font>(m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00325 {
00326 uint32 wtmp, htmp;
00327 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a><4)
00328 wtmp = 4;
00329 <font class="keywordflow">else</font>
00330 wtmp = <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;
00331 <font class="keywordflow">if</font>(h < 4)
00332 htmp = 4;
00333 <font class="keywordflow">else</font>
00334 htmp = h;
00335
00336 uint32 mipMapSz;
00337 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>==<a class="code" href="classNLMISC_1_1CBitmap.html#s11s4">DXTC1</a> || <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>==<a class="code" href="classNLMISC_1_1CBitmap.html#s11s5">DXTC1Alpha</a>)
00338 mipMapSz = wtmp*htmp/2;
00339 <font class="keywordflow">else</font>
00340 mipMapSz = wtmp*htmp;
00341
00342
00343 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].resize(mipMapSz);
00344 totalSize+= mipMapSz;
00345
00346 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>+1)/2;
00347 h = (h+1)/2;
00348 }
00349
00350 <font class="comment">// Read all the data in one block.</font>
00351 vector<uint8> pixData;
00352 pixData.resize(totalSize);
00353 f.<a class="code" href="classNLMISC_1_1IStream.html#z327_0">serialBuffer</a>(&(*pixData.begin()), totalSize);
00354
00355
00356 <font class="comment">//------------- reading mipmap levels from pixData</font>
00357
00358 uint32 pixIndex= 0;
00359
00360 <font class="keywordflow">for</font>(m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00361 {
00362 uint32 mipMapSz= <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size();
00363 memcpy(&(*<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].begin()), &(pixData[pixIndex]), mipMapSz);
00364 pixIndex+= mipMapSz;
00365 }
00366
00367 <font class="comment">//------------- End</font>
00368
00369 <font class="keywordflow">switch</font>(PixelFormat)
00370 {
00371 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s4">DXTC1</a> : <font class="keywordflow">return</font> 24;
00372 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s5">DXTC1Alpha</a> : <font class="keywordflow">return</font> 32;
00373 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s6">DXTC3</a> : <font class="keywordflow">return</font> 32;
00374 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s7">DXTC5</a> : <font class="keywordflow">return</font> 32;
00375 <font class="keywordflow">default</font> : <font class="keywordflow">break</font>;
00376 }
00377
00378 <font class="keywordflow">return</font> 0;
00379 }
00380
00381
00382
00383
00384 <font class="comment">/*-------------------------------------------------------------------*\</font>
00385 <font class="comment"> convertToDXTC5</font>
00386 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00387"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_0">00387</a> <font class="keywordtype">bool</font> CBitmap::convertToDXTC5()
00388 {
00389 <font class="comment">/* Yoyo: RGB encoding for DXTC1 and DXTC5/3 are actually different!!</font>
00390 <font class="comment"> DXTC3/5 don't rely on sign of color0>color1 to setup special encoding (ie use a special compression for Black)</font>
00391 <font class="comment"> Since this can arise if the src is DXTC1 , we can't simply compress it into DXTC5 without doing a </font>
00392 <font class="comment"> heavy compression...</font>
00393 <font class="comment"> (the inverse is false: DXTC5 to DXTC1 is possible, with maybe swap color0/color1 and bits).</font>
00394 <font class="comment"> */</font>
00395
00396 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00397
00398 <font class="comment">/* uint32 i,j;</font>
00399 <font class="comment"></font>
00400 <font class="comment"> if(PixelFormat!=DXTC1) return false;</font>
00401 <font class="comment"></font>
00402 <font class="comment"> for(uint8 m= 0; m<_MipMapCount; m++)</font>
00403 <font class="comment"> {</font>
00404 <font class="comment"> std::vector<uint8> dataTmp;</font>
00405 <font class="comment"> dataTmp.reserve(2*_Data[m].size());</font>
00406 <font class="comment"></font>
00407 <font class="comment"> for(i=0; i<_Data[m].size(); i+=8)</font>
00408 <font class="comment"> {</font>
00409 <font class="comment"> //64 bits alpha</font>
00410 <font class="comment"> for(j=0; j<8; j++)</font>
00411 <font class="comment"> {</font>
00412 <font class="comment"> dataTmp.push_back(255);</font>
00413 <font class="comment"> }</font>
00414 <font class="comment"></font>
00415 <font class="comment"> //64 bits RGB</font>
00416 <font class="comment"> for(j=0; j<8; j++)</font>
00417 <font class="comment"> {</font>
00418 <font class="comment"> dataTmp.push_back(_Data[m][i+j]);</font>
00419 <font class="comment"> }</font>
00420 <font class="comment"> }</font>
00421 <font class="comment"> _Data[m] = dataTmp;</font>
00422 <font class="comment"> }</font>
00423 <font class="comment"> PixelFormat = DXTC5;</font>
00424 <font class="comment"> return true;</font>
00425 <font class="comment">*/</font>
00426 }
00427
00428
00429
00430 <font class="comment">/*-------------------------------------------------------------------*\</font>
00431 <font class="comment"> luminanceToRGBA()</font>
00432 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00433"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_2">00433</a> <font class="keywordtype">bool</font> CBitmap::luminanceToRGBA()
00434 {
00435 uint32 i;
00436
00437 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> == 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
00438
00439 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00440 {
00441 std::vector<uint8> dataTmp;
00442 dataTmp.reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].<a class="code" href="cf__lexical_8cpp.html#a94">size</a>()*4);
00443
00444 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i++)
00445 {
00446 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]);
00447 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]);
00448 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]);
00449 dataTmp.push_back(255);
00450 }
00451 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m] = dataTmp;
00452 }
00453 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>;
00454 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00455 }
00456
00457 <font class="comment">/*-------------------------------------------------------------------*\</font>
00458 <font class="comment"> alphaToRGBA()</font>
00459 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00460"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_3">00460</a> <font class="keywordtype">bool</font> CBitmap::alphaToRGBA()
00461 {
00462 uint32 i;
00463
00464 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> == 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
00465
00466 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00467 {
00468 std::vector<uint8> dataTmp;
00469 dataTmp.reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].<a class="code" href="cf__lexical_8cpp.html#a94">size</a>()*4);
00470
00471 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i++)
00472 {
00473 dataTmp.push_back(255);
00474 dataTmp.push_back(255);
00475 dataTmp.push_back(255);
00476 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]);
00477 }
00478 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m] = dataTmp;
00479 }
00480 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>;
00481 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00482 }
00483
00484
00485 <font class="comment">/*-------------------------------------------------------------------*\</font>
00486 <font class="comment"> alphaLuminanceToRGBA()</font>
00487 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00488"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_4">00488</a> <font class="keywordtype">bool</font> CBitmap::alphaLuminanceToRGBA()
00489 {
00490 uint32 i;
00491
00492 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> == 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
00493
00494 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00495 {
00496 std::vector<uint8> dataTmp;
00497 dataTmp.reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].<a class="code" href="cf__lexical_8cpp.html#a94">size</a>()*2);
00498
00499 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i+=2)
00500 {
00501 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]);
00502 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]);
00503 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]);
00504 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+1]);
00505 }
00506 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m] = dataTmp;
00507 }
00508 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>;
00509 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00510 }
00511
00512
00513
00514
00515 <font class="comment">/*-------------------------------------------------------------------*\</font>
00516 <font class="comment"> rgbaToAlphaLuminance</font>
00517 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00518"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_14">00518</a> <font class="keywordtype">bool</font> CBitmap::rgbaToAlphaLuminance()
00519 {
00520 uint32 i;
00521
00522 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> == 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
00523
00524 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00525 {
00526 std::vector<uint8> dataTmp;
00527 dataTmp.reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].<a class="code" href="cf__lexical_8cpp.html#a94">size</a>()/2);
00528
00529 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i+=4)
00530 {
00531 dataTmp.push_back((<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]*77 + <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+1]*150 + <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+2]*28)/255);
00532 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+3]);
00533 }
00534 <a class="code" href="namespaceNLMISC.html#a222">NLMISC::contReset</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m]);
00535 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].resize(0);
00536 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m] = dataTmp;
00537 }
00538 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s3">AlphaLuminance</a>;
00539 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00540 }
00541
00542
00543 <font class="comment">/*-------------------------------------------------------------------*\</font>
00544 <font class="comment"> luminanceToAlphaLuminance</font>
00545 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00546"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_15">00546</a> <font class="keywordtype">bool</font> CBitmap::luminanceToAlphaLuminance()
00547 {
00548 uint32 i;
00549
00550 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> == 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
00551
00552 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00553 {
00554 std::vector<uint8> dataTmp;
00555 dataTmp.reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].<a class="code" href="cf__lexical_8cpp.html#a94">size</a>()*2);
00556
00557 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i++)
00558 {
00559 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]);
00560 dataTmp.push_back(255);
00561 }
00562 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m] = dataTmp;
00563 }
00564 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s3">AlphaLuminance</a>;
00565 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00566 }
00567
00568
00569
00570 <font class="comment">/*-------------------------------------------------------------------*\</font>
00571 <font class="comment"> alphaToAlphaLuminance</font>
00572 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00573"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_16">00573</a> <font class="keywordtype">bool</font> CBitmap::alphaToAlphaLuminance()
00574 {
00575 uint32 i;
00576
00577 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> == 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
00578
00579 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00580 {
00581 std::vector<uint8> dataTmp;
00582 dataTmp.reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].<a class="code" href="cf__lexical_8cpp.html#a94">size</a>()*2);
00583
00584 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i++)
00585 {
00586 dataTmp.push_back(0);
00587 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]);
00588 }
00589 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m] = dataTmp;
00590 }
00591 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s3">AlphaLuminance</a>;
00592 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00593 }
00594
00595
00596
00597 <font class="comment">/*-------------------------------------------------------------------*\</font>
00598 <font class="comment"> rgbaToLuminance</font>
00599 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00600"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_6">00600</a> <font class="keywordtype">bool</font> CBitmap::rgbaToLuminance()
00601 {
00602 uint32 i;
00603
00604 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> == 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
00605
00606 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00607 {
00608 std::vector<uint8> dataTmp;
00609 dataTmp.reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].<a class="code" href="cf__lexical_8cpp.html#a94">size</a>()/4);
00610
00611 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i+=4)
00612 {
00613 dataTmp.push_back((<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]*77 + <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+1]*150 + <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+2]*28)/255);
00614 }
00615 <a class="code" href="namespaceNLMISC.html#a222">NLMISC::contReset</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m]);
00616 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].resize(0);
00617 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m] = dataTmp;
00618 }
00619 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s1">Luminance</a>;
00620 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00621 }
00622
00623
00624
00625 <font class="comment">/*-------------------------------------------------------------------*\</font>
00626 <font class="comment"> alphaToLuminance</font>
00627 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00628"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_7">00628</a> <font class="keywordtype">bool</font> CBitmap::alphaToLuminance()
00629 {
00630 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> == 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
00631
00632 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s1">Luminance</a>;
00633 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00634 }
00635
00636
00637
00638 <font class="comment">/*-------------------------------------------------------------------*\</font>
00639 <font class="comment"> alphaLuminanceToLuminance</font>
00640 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00641"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_8">00641</a> <font class="keywordtype">bool</font> CBitmap::alphaLuminanceToLuminance()
00642 {
00643 uint32 i;
00644
00645 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> == 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
00646
00647 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00648 {
00649 std::vector<uint8> dataTmp;
00650 dataTmp.reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].<a class="code" href="cf__lexical_8cpp.html#a94">size</a>()/2);
00651
00652 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i+=2)
00653 {
00654 dataTmp.push_back(0);
00655 dataTmp.push_back(0);
00656 dataTmp.push_back(0);
00657 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]);
00658 }
00659 <a class="code" href="namespaceNLMISC.html#a222">NLMISC::contReset</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m]);
00660 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].resize(0);
00661 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m] = dataTmp;
00662 }
00663 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s1">Luminance</a>;
00664 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00665 }
00666
00667
00668 <font class="comment">/*-------------------------------------------------------------------*\</font>
00669 <font class="comment"> rgbaToAlpha</font>
00670 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00671"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_10">00671</a> <font class="keywordtype">bool</font> CBitmap::rgbaToAlpha()
00672 {
00673 uint32 i;
00674
00675 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> == 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
00676
00677 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00678 {
00679 std::vector<uint8> dataTmp;
00680 dataTmp.reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].<a class="code" href="cf__lexical_8cpp.html#a94">size</a>()/4);
00681
00682 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i+=4)
00683 {
00684 dataTmp.push_back(0);
00685 dataTmp.push_back(0);
00686 dataTmp.push_back(0);
00687 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+3]);
00688 }
00689 <a class="code" href="namespaceNLMISC.html#a222">NLMISC::contReset</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m]);
00690 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].resize(0);
00691 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m] = dataTmp;
00692 }
00693 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>;
00694 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00695 }
00696
00697
00698 <font class="comment">/*-------------------------------------------------------------------*\</font>
00699 <font class="comment"> luminanceToAlpha</font>
00700 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00701"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_11">00701</a> <font class="keywordtype">bool</font> CBitmap::luminanceToAlpha()
00702 {
00703 uint32 i;
00704
00705 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> == 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
00706
00707 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00708 {
00709 std::vector<uint8> dataTmp;
00710 dataTmp.reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].<a class="code" href="cf__lexical_8cpp.html#a94">size</a>());
00711
00712 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i++)
00713 {
00714 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i]);
00715 }
00716 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m] = dataTmp;
00717 }
00718 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>;
00719 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00720 }
00721
00722
00723 <font class="comment">/*-------------------------------------------------------------------*\</font>
00724 <font class="comment"> alphaLuminanceToAlpha</font>
00725 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00726"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_12">00726</a> <font class="keywordtype">bool</font> CBitmap::alphaLuminanceToAlpha()
00727 {
00728 uint32 i;
00729
00730 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> == 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
00731
00732 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00733 {
00734 std::vector<uint8> dataTmp;
00735 dataTmp.reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].<a class="code" href="cf__lexical_8cpp.html#a94">size</a>()/2);
00736
00737 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i+=2)
00738 {
00739 dataTmp.push_back(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+1]);
00740 }
00741 <a class="code" href="namespaceNLMISC.html#a222">NLMISC::contReset</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m]);
00742 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].resize(0);
00743 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m] = dataTmp;
00744 }
00745 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>;
00746 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00747 }
00748
00749
00750 <font class="comment">/*-------------------------------------------------------------------*\</font>
00751 <font class="comment"> convertToLuminance</font>
00752 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00753"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_5">00753</a> <font class="keywordtype">bool</font> CBitmap::convertToLuminance()
00754 {
00755 <font class="keywordflow">switch</font>(PixelFormat)
00756 {
00757 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a> :
00758 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_6">rgbaToLuminance</a>();
00759 <font class="keywordflow">break</font>;
00760
00761 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s1">Luminance</a> :
00762 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00763 <font class="keywordflow">break</font>;
00764
00765 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a> :
00766 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_7">alphaToLuminance</a>();
00767 <font class="keywordflow">break</font>;
00768
00769 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s3">AlphaLuminance</a> :
00770 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_8">alphaLuminanceToLuminance</a>();
00771 <font class="keywordflow">break</font>;
00772
00773 <font class="keywordflow">default</font>:
00774 <font class="keywordflow">break</font>;
00775 }
00776 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00777 }
00778
00779
00780
00781 <font class="comment">/*-------------------------------------------------------------------*\</font>
00782 <font class="comment"> convertToAlpha</font>
00783 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00784"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_9">00784</a> <font class="keywordtype">bool</font> CBitmap::convertToAlpha()
00785 {
00786 <font class="keywordflow">switch</font>(PixelFormat)
00787 {
00788 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a> :
00789 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_10">rgbaToAlpha</a>();
00790 <font class="keywordflow">break</font>;
00791
00792 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s1">Luminance</a> :
00793 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_11">luminanceToAlpha</a>();
00794 <font class="keywordflow">break</font>;
00795
00796 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a> :
00797 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00798 <font class="keywordflow">break</font>;
00799
00800 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s3">AlphaLuminance</a> :
00801 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_12">alphaLuminanceToAlpha</a>();
00802 <font class="keywordflow">break</font>;
00803
00804 <font class="keywordflow">default</font>:
00805 <font class="keywordflow">break</font>;
00806 }
00807 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00808 }
00809
00810
00811
00812 <font class="comment">/*-------------------------------------------------------------------*\</font>
00813 <font class="comment"> convertToAlphaLuminance</font>
00814 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00815"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_13">00815</a> <font class="keywordtype">bool</font> CBitmap::convertToAlphaLuminance()
00816 {
00817 <font class="keywordflow">switch</font>(PixelFormat)
00818 {
00819 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a> :
00820 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_14">rgbaToAlphaLuminance</a>();
00821 <font class="keywordflow">break</font>;
00822
00823 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s1">Luminance</a> :
00824 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_15">luminanceToAlphaLuminance</a>();
00825 <font class="keywordflow">break</font>;
00826
00827 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a> :
00828 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_16">alphaToAlphaLuminance</a>();
00829 <font class="keywordflow">break</font>;
00830
00831 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s3">AlphaLuminance</a> :
00832 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00833 <font class="keywordflow">break</font>;
00834
00835 <font class="keywordflow">default</font>:
00836 <font class="keywordflow">break</font>;
00837 }
00838 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00839 }
00840
00841
00842 <font class="comment">/*-------------------------------------------------------------------*\</font>
00843 <font class="comment"> convertToRGBA</font>
00844 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00845"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z275_1">00845</a> <font class="keywordtype">bool</font> CBitmap::convertToRGBA()
00846 {
00847 <font class="keywordflow">switch</font>(PixelFormat)
00848 {
00849 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s4">DXTC1</a> :
00850 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#c3">decompressDXT1</a>(<font class="keyword">false</font>);
00851 <font class="keywordflow">break</font>;
00852
00853 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s5">DXTC1Alpha</a> :
00854 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#c3">decompressDXT1</a>(<font class="keyword">true</font>);
00855 <font class="keywordflow">break</font>;
00856
00857 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s6">DXTC3</a> :
00858 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#c4">decompressDXT3</a>();
00859 <font class="keywordflow">break</font>;
00860
00861 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s7">DXTC5</a> :
00862 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#c5">decompressDXT5</a>();
00863 <font class="keywordflow">break</font>;
00864
00865 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s1">Luminance</a> :
00866 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_2">luminanceToRGBA</a>();
00867 <font class="keywordflow">break</font>;
00868
00869 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a> :
00870 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_3">alphaToRGBA</a>();
00871 <font class="keywordflow">break</font>;
00872
00873 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s3">AlphaLuminance</a> :
00874 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_4">alphaLuminanceToRGBA</a>();
00875 <font class="keywordflow">break</font>;
00876 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>:
00877 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00878 <font class="keywordflow">break</font>;
00879 <font class="keywordflow">default</font>:
00880 <font class="keywordflow">break</font>;
00881 }
00882 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00883 }
00884
00885
00886 <font class="comment">/*-------------------------------------------------------------------*\</font>
00887 <font class="comment"> convertToType</font>
00888 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00889"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a4">00889</a> <font class="keywordtype">bool</font> CBitmap::convertToType(CBitmap::TType <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>)
00890 {
00891 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>==<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>) <font class="keywordflow">return</font> <font class="keyword">true</font>;
00892
00893 <font class="keywordflow">switch</font>(type)
00894 {
00895 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a> :
00896 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_1">convertToRGBA</a>();
00897 <font class="keywordflow">break</font>;
00898
00899 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s7">DXTC5</a> :
00900 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_0">convertToDXTC5</a>();
00901 <font class="keywordflow">break</font>;
00902
00903 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s1">Luminance</a> :
00904 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_5">convertToLuminance</a>();
00905 <font class="keywordflow">break</font>;
00906
00907 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a> :
00908 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_9">convertToAlpha</a>();
00909 <font class="keywordflow">break</font>;
00910
00911 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s3">AlphaLuminance</a> :
00912 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z275_13">convertToAlphaLuminance</a>();
00913 <font class="keywordflow">break</font>;
00914
00915 <font class="keywordflow">default</font>:
00916 <font class="keywordflow">break</font>;
00917 }
00918
00919 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00920 }
00921
00922
00923
00924
00925 <font class="comment">/*-------------------------------------------------------------------*\</font>
00926 <font class="comment"> decompressDXT1</font>
00927 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l00928"></a><a class="code" href="classNLMISC_1_1CBitmap.html#c3">00928</a> <font class="keywordtype">bool</font> CBitmap::decompressDXT1(<font class="keywordtype">bool</font> <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>)
00929 {
00930 uint32 i,j,k;
00931 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> c[4];
00932 std::vector<uint8> dataTmp[<a class="code" href="namespaceNLMISC.html#a4">MAX_MIPMAP</a>];
00933
00934 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>= <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
00935 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>= <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
00936
00937 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
00938 {
00939 uint32 wtmp, htmp;
00940 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a><4)
00941 wtmp = 4;
00942 <font class="keywordflow">else</font>
00943 wtmp = <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;
00944 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> < 4)
00945 htmp = 4;
00946 <font class="keywordflow">else</font>
00947 htmp = <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
00948 uint32 mipMapSz = wtmp*htmp*4;
00949 dataTmp[m].resize(mipMapSz);
00950 <font class="keywordflow">if</font>(dataTmp[m].capacity()<mipMapSz)
00951 {
00952 <font class="keywordflow">throw</font> EAllocationFailure();
00953 }
00954 uint32 wBlockCount= wtmp/4;
00955
00956
00957
00958 <font class="keywordflow">for</font>(i=0; i < <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i+=8)
00959 {
00960 uint16 color0;
00961 uint16 color1;
00962 uint32 bits;
00963 memcpy(&color0,&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i],2);
00964 memcpy(&color1,&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+2],2);
00965 memcpy(&bits,&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+4],4);
00966
00967 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(color0,c[0]);
00968 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(color1,c[1]);
00969
00970 c[0].<a class="code" href="classNLMISC_1_1CRGBA.html#m3">A</a>= 0;
00971 c[1].<a class="code" href="classNLMISC_1_1CRGBA.html#m3">A</a>= 0;
00972 c[2].<a class="code" href="classNLMISC_1_1CRGBA.html#m3">A</a>= 0;
00973 c[3].<a class="code" href="classNLMISC_1_1CRGBA.html#m3">A</a>= 0;
00974
00975 <font class="keywordflow">if</font>(color0>color1)
00976 {
00977 c[2].<a class="code" href="classNLMISC_1_1CRGBA.html#a7">blendFromui</a>(c[0],c[1],85);
00978 <font class="keywordflow">if</font>(alpha) c[2].<a class="code" href="classNLMISC_1_1CRGBA.html#m3">A</a>= 255;
00979
00980 c[3].<a class="code" href="classNLMISC_1_1CRGBA.html#a7">blendFromui</a>(c[0],c[1],171);
00981 <font class="keywordflow">if</font>(alpha) c[3].<a class="code" href="classNLMISC_1_1CRGBA.html#m3">A</a>= 255;
00982 }
00983 <font class="keywordflow">else</font>
00984 {
00985 c[2].<a class="code" href="classNLMISC_1_1CRGBA.html#a7">blendFromui</a>(c[0],c[1],128);
00986 <font class="keywordflow">if</font>(alpha) c[2].<a class="code" href="classNLMISC_1_1CRGBA.html#m3">A</a>= 255;
00987
00988 c[3].<a class="code" href="classNLMISC_1_1CRGBA.html#a10">set</a>(0,0,0,0);
00989 }
00990
00991 <font class="comment">// computing the 16 RGBA of the block</font>
00992
00993 uint32 blockNum= i/8; <font class="comment">//(64 bits)</font>
00994 <font class="comment">// <previous blocks in above lines> * 4 (rows) * _Width (columns) + 4pix*4rgba*<same line previous blocks></font>
00995 uint32 pixelsCount= 4*(blockNum/wBlockCount)*wtmp*4 + 4*4*(blockNum%wBlockCount);
00996 <font class="keywordflow">for</font>(j=0; j<4; j++)
00997 {
00998 <font class="keywordflow">for</font>(k=0; k<4; k++)
00999 {
01000 dataTmp[m][pixelsCount + j*wtmp*4 + 4*k]= c[bits&3].<a class="code" href="classNLMISC_1_1CRGBA.html#m0">R</a>;
01001 dataTmp[m][pixelsCount + j*wtmp*4 + 4*k+1]= c[bits&3].<a class="code" href="classNLMISC_1_1CRGBA.html#m1">G</a>;
01002 dataTmp[m][pixelsCount + j*wtmp*4 + 4*k+2]= c[bits&3].<a class="code" href="classNLMISC_1_1CRGBA.html#m2">B</a>;
01003 dataTmp[m][pixelsCount + j*wtmp*4 + 4*k+3]= c[bits&3].<a class="code" href="classNLMISC_1_1CRGBA.html#m3">A</a>;
01004 bits>>=2;
01005 }
01006 }
01007 }
01008
01009 <font class="comment">// Copy result into the mipmap level.</font>
01010 <font class="keywordflow">if</font>(wtmp==<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> && htmp==<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>)
01011 {
01012 <font class="comment">// For mipmaps level >4 pixels.</font>
01013 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m]= dataTmp[m];
01014 }
01015 <font class="keywordflow">else</font>
01016 {
01017 <font class="comment">// For last mipmaps, level <4 pixels.</font>
01018 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].resize(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>*4);
01019 CRGBA *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= (CRGBA*)&dataTmp[m][0];
01020 CRGBA *dst= (CRGBA*)&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][0];
01021 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
01022 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a><<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
01023 {
01024 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a><<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
01025 dst[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>]= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*wtmp+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>];
01026 }
01027 }
01028
01029 <font class="comment">// Next mipmap size.</font>
01030 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> = (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>+1)/2;
01031 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> = (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>+1)/2;
01032 }
01033 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>;
01034 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01035 }
01036
01037
01038
01039
01040 <font class="comment">/*-------------------------------------------------------------------*\</font>
01041 <font class="comment"> decompressDXT3</font>
01042 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01043"></a><a class="code" href="classNLMISC_1_1CBitmap.html#c4">01043</a> <font class="keywordtype">bool</font> CBitmap::decompressDXT3()
01044 {
01045 uint32 i,j,k;
01046 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> c[4];
01047 std::vector<uint8> dataTmp[<a class="code" href="namespaceNLMISC.html#a4">MAX_MIPMAP</a>];
01048
01049 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>= <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
01050 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>= <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
01051
01052 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
01053 {
01054 uint32 wtmp, htmp;
01055 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a><4)
01056 wtmp = 4;
01057 <font class="keywordflow">else</font>
01058 wtmp = <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;
01059 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> < 4)
01060 htmp = 4;
01061 <font class="keywordflow">else</font>
01062 htmp = <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
01063 uint32 mipMapSz = wtmp*htmp*4;
01064 dataTmp[m].resize(mipMapSz);
01065 <font class="keywordflow">if</font>(dataTmp[m].capacity()<mipMapSz)
01066 {
01067 <font class="keywordflow">throw</font> EAllocationFailure();
01068 }
01069 uint32 wBlockCount= wtmp/4;
01070
01071
01072 <font class="keywordflow">for</font>(i=0; i < <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i+=16)
01073 {
01074 uint8 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[16];
01075 uint64 alphatmp;
01076 memcpy(&alphatmp,&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i],8);
01077
01078 <font class="keywordflow">for</font>(j=0; j<16; j++)
01079 {
01080 uint8 a= (uint8)(alphatmp&15);
01081 <font class="comment">// expand to 0-255.</font>
01082 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[j]= a+(a<<4);
01083 alphatmp>>=4;
01084 }
01085
01086
01087 uint16 color0;
01088 uint16 color1;
01089 uint32 bits;
01090 memcpy(&color0,&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+8],2);
01091 memcpy(&color1,&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+10],2);
01092 memcpy(&bits,&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+12],4);
01093
01094 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(color0,c[0]);
01095 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(color1,c[1]);
01096
01097 <font class="comment">// ignore color0>color1 for DXT3 and DXT5.</font>
01098 c[2].<a class="code" href="classNLMISC_1_1CRGBA.html#a7">blendFromui</a>(c[0],c[1],85);
01099 c[3].<a class="code" href="classNLMISC_1_1CRGBA.html#a7">blendFromui</a>(c[0],c[1],171);
01100
01101 <font class="comment">// computing the 16 RGBA of the block</font>
01102
01103 uint32 blockNum= i/16; <font class="comment">//(128 bits)</font>
01104 <font class="comment">// <previous blocks in above lines> * 4 (rows) * wtmp (columns) + 4pix*4rgba*<same line previous blocks></font>
01105 uint32 pixelsCount= 4*(blockNum/wBlockCount)*wtmp*4 + 4*4*(blockNum%wBlockCount);
01106 <font class="keywordflow">for</font>(j=0; j<4; j++)
01107 {
01108 <font class="keywordflow">for</font>(k=0; k<4; k++)
01109 {
01110 dataTmp[m][pixelsCount + j*wtmp*4 + 4*k]= c[bits&3].<a class="code" href="classNLMISC_1_1CRGBA.html#m0">R</a>;
01111 dataTmp[m][pixelsCount + j*wtmp*4 + 4*k+1]= c[bits&3].<a class="code" href="classNLMISC_1_1CRGBA.html#m1">G</a>;
01112 dataTmp[m][pixelsCount + j*wtmp*4 + 4*k+2]= c[bits&3].<a class="code" href="classNLMISC_1_1CRGBA.html#m2">B</a>;
01113 dataTmp[m][pixelsCount + j*wtmp*4 + 4*k+3]= <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[4*j+k];
01114 bits>>=2;
01115 }
01116 }
01117 }
01118
01119 <font class="comment">// Copy result into the mipmap level.</font>
01120 <font class="keywordflow">if</font>(wtmp==<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> && htmp==<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>)
01121 {
01122 <font class="comment">// For mipmaps level >4 pixels.</font>
01123 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m]= dataTmp[m];
01124 }
01125 <font class="keywordflow">else</font>
01126 {
01127 <font class="comment">// For last mipmaps, level <4 pixels.</font>
01128 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].resize(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>*4);
01129 CRGBA *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= (CRGBA*)&dataTmp[m][0];
01130 CRGBA *dst= (CRGBA*)&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][0];
01131 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
01132 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a><<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
01133 {
01134 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a><<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
01135 dst[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>]= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*wtmp+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>];
01136 }
01137 }
01138
01139 <font class="comment">// Next mipmap size.</font>
01140 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> = (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>+1)/2;
01141 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> = (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>+1)/2;
01142 }
01143 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>;
01144 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01145 }
01146
01147
01148
01149
01150 <font class="comment">/*-------------------------------------------------------------------*\</font>
01151 <font class="comment"> decompressDXT5</font>
01152 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01153"></a><a class="code" href="classNLMISC_1_1CBitmap.html#c5">01153</a> <font class="keywordtype">bool</font> CBitmap::decompressDXT5()
01154 {
01155 uint32 i,j,k;
01156 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> c[4];
01157 std::vector<uint8> dataTmp[<a class="code" href="namespaceNLMISC.html#a4">MAX_MIPMAP</a>];
01158
01159 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>= <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
01160 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>= <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
01161
01162 <font class="keywordflow">for</font>(uint8 m= 0; m<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; m++)
01163 {
01164 uint32 wtmp, htmp;
01165 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a><4)
01166 wtmp = 4;
01167 <font class="keywordflow">else</font>
01168 wtmp = <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;
01169 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> < 4)
01170 htmp = 4;
01171 <font class="keywordflow">else</font>
01172 htmp = <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
01173 uint32 mipMapSz = wtmp*htmp*4;
01174 dataTmp[m].resize(mipMapSz);
01175 <font class="keywordflow">if</font>(dataTmp[m].capacity()<mipMapSz)
01176 {
01177 <font class="keywordflow">throw</font> EAllocationFailure();
01178 }
01179 uint32 wBlockCount= wtmp/4;
01180
01181
01182
01183 <font class="keywordflow">for</font>(i=0; i < <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].size(); i+=16)
01184 {
01185 uint64 bitsAlpha;
01186 memcpy(&bitsAlpha,&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i],8);
01187 bitsAlpha>>= 16;
01188
01189 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[8];
01190 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[0]= <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+0];
01191 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[1]= <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+1];
01192
01193 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[0]><a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[1])
01194 {
01195 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[2]= <a class="code" href="classNLMISC_1_1CBitmap.html#c0">blend</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[0], <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[1], 219);
01196 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[3]= <a class="code" href="classNLMISC_1_1CBitmap.html#c0">blend</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[0], <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[1], 183);
01197 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[4]= <a class="code" href="classNLMISC_1_1CBitmap.html#c0">blend</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[0], <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[1], 146);
01198 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[5]= <a class="code" href="classNLMISC_1_1CBitmap.html#c0">blend</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[0], <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[1], 110);
01199 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[6]= <a class="code" href="classNLMISC_1_1CBitmap.html#c0">blend</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[0], <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[1], 73);
01200 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[7]= <a class="code" href="classNLMISC_1_1CBitmap.html#c0">blend</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[0], <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[1], 37);
01201 }
01202 <font class="keywordflow">else</font>
01203 {
01204 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[2]= <a class="code" href="classNLMISC_1_1CBitmap.html#c0">blend</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[0], <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[1], 204);
01205 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[3]= <a class="code" href="classNLMISC_1_1CBitmap.html#c0">blend</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[0], <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[1], 154);
01206 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[4]= <a class="code" href="classNLMISC_1_1CBitmap.html#c0">blend</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[0], <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[1], 102);
01207 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[5]= <a class="code" href="classNLMISC_1_1CBitmap.html#c0">blend</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[0], <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[1], 51);
01208 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[6]= 0;
01209 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[7]= 255;
01210 }
01211
01212 uint8 codeAlpha[16];
01213 <font class="keywordflow">for</font>(j=0; j<16; j++)
01214 {
01215 codeAlpha[j] = (uint8)bitsAlpha & 7;
01216 bitsAlpha>>=3;
01217 }
01218
01219
01220 uint16 color0;
01221 uint16 color1;
01222 uint32 bits;
01223 memcpy(&color0,&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+8],2);
01224 memcpy(&color1,&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+10],2);
01225 memcpy(&bits,&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][i+12],4);
01226
01227 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(color0,c[0]);
01228 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(color1,c[1]);
01229
01230 <font class="comment">// ignore color0>color1 for DXT3 and DXT5.</font>
01231 c[2].<a class="code" href="classNLMISC_1_1CRGBA.html#a7">blendFromui</a>(c[0],c[1],85);
01232 c[3].<a class="code" href="classNLMISC_1_1CRGBA.html#a7">blendFromui</a>(c[0],c[1],171);
01233
01234 <font class="comment">// computing the 16 RGBA of the block</font>
01235
01236 uint32 blockNum= i/16; <font class="comment">//(128 bits)</font>
01237
01238 <font class="comment">// <previous blocks in above lines> * 4 (rows) * wtmp (columns) + 4pix*<same line previous blocks></font>
01239 uint32 pixelsCount= (blockNum/wBlockCount)*wtmp*4 + 4*(blockNum%wBlockCount);
01240 <font class="comment">// *sizeof(RGBA)</font>
01241 pixelsCount*=4;
01242 <font class="keywordflow">for</font>(j=0; j<4; j++)
01243 {
01244 <font class="keywordflow">for</font>(k=0; k<4; k++)
01245 {
01246 dataTmp[m][pixelsCount + (j*wtmp+k)*4 +0]= c[bits&3].<a class="code" href="classNLMISC_1_1CRGBA.html#m0">R</a>;
01247 dataTmp[m][pixelsCount + (j*wtmp+k)*4 +1]= c[bits&3].<a class="code" href="classNLMISC_1_1CRGBA.html#m1">G</a>;
01248 dataTmp[m][pixelsCount + (j*wtmp+k)*4 +2]= c[bits&3].<a class="code" href="classNLMISC_1_1CRGBA.html#m2">B</a>;
01249 dataTmp[m][pixelsCount + (j*wtmp+k)*4 +3]= (uint8) <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>[codeAlpha[4*j+k]];
01250 bits>>=2;
01251 }
01252 }
01253
01254 }
01255
01256 <font class="comment">// Copy result into the mipmap level.</font>
01257 <font class="keywordflow">if</font>(wtmp==<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> && htmp==<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>)
01258 {
01259 <font class="comment">// For mipmaps level >4 pixels.</font>
01260 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m]= dataTmp[m];
01261 }
01262 <font class="keywordflow">else</font>
01263 {
01264 <font class="comment">// For last mipmaps, level <4 pixels.</font>
01265 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m].resize(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>*4);
01266 CRGBA *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= (CRGBA*)&dataTmp[m][0];
01267 CRGBA *dst= (CRGBA*)&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[m][0];
01268 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
01269 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a><<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
01270 {
01271 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a><<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
01272 dst[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>]= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*wtmp+<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>];
01273 }
01274 }
01275
01276 <font class="comment">// Next mipmap size.</font>
01277 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> = (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>+1)/2;
01278 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> = (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>+1)/2;
01279 }
01280 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>;
01281 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01282
01283 }
01284
01285
01286
01287
01288 <font class="comment">/*-------------------------------------------------------------------*\</font>
01289 <font class="comment"> blend</font>
01290 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01291"></a><a class="code" href="classNLMISC_1_1CBitmap.html#c0">01291</a> uint32 CBitmap::blend(uint32 &n0, uint32 &n1, uint32 coef0)
01292 {
01293 <font class="keywordtype">int</font> a0 = coef0;
01294 <font class="keywordtype">int</font> a1 = 256-a0;
01295 <font class="keywordflow">return</font> ((n0*a0 + n1*a1) >>8);
01296 }
01297
01298
01299
01300 <font class="comment">/*-------------------------------------------------------------------*\</font>
01301 <font class="comment"> uncompress</font>
01302 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01303"></a><a class="code" href="classNLMISC_1_1CBitmap.html#f0">01303</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CBitmap::uncompress(uint16 color, <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> &<a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>)
01304 {
01305 r.<a class="code" href="classNLMISC_1_1CRGBA.html#m3">A</a>= 0;
01306 r.<a class="code" href="classNLMISC_1_1CRGBA.html#m0">R</a>= ((color>>11)&31) << 3; r.<a class="code" href="classNLMISC_1_1CRGBA.html#m0">R</a>+= r.<a class="code" href="classNLMISC_1_1CRGBA.html#m0">R</a>>>5;
01307 r.<a class="code" href="classNLMISC_1_1CRGBA.html#m1">G</a>= ((color>>5)&63) << 2; r.<a class="code" href="classNLMISC_1_1CRGBA.html#m1">G</a>+= r.<a class="code" href="classNLMISC_1_1CRGBA.html#m1">G</a>>>6;
01308 r.<a class="code" href="classNLMISC_1_1CRGBA.html#m2">B</a>= ((color)&31) << 3; r.<a class="code" href="classNLMISC_1_1CRGBA.html#m2">B</a>+= r.<a class="code" href="classNLMISC_1_1CRGBA.html#m2">B</a>>>5;
01309 }
01310
01311
01312
01313 <font class="comment">/*-------------------------------------------------------------------*\</font>
01314 <font class="comment"> getWidth</font>
01315 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01316"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a6">01316</a> uint32 CBitmap::getWidth(uint32 mipMap)<font class="keyword"> const</font>
01317 <font class="keyword"></font>{
01318 <font class="keywordflow">if</font>(mipMap==0) <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
01319
01320 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
01321 uint32 h = <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
01322 uint32 m = 0;
01323
01324 <font class="keywordflow">do</font>
01325 {
01326 m++;
01327 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>+1)/2;
01328 h = (h+1)/2;
01329 <font class="keywordflow">if</font>(m==mipMap) <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;
01330 }
01331 <font class="keywordflow">while</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>!=1 || h!=1);
01332
01333 <font class="keywordflow">return</font> 0;
01334 }
01335
01336
01337
01338 <font class="comment">/*-------------------------------------------------------------------*\</font>
01339 <font class="comment"> getHeight</font>
01340 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01341"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a7">01341</a> uint32 CBitmap::getHeight(uint32 mipMap)<font class="keyword"> const</font>
01342 <font class="keyword"></font>{
01343 <font class="keywordflow">if</font>(mipMap==0) <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
01344
01345 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
01346 uint32 h = <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
01347 uint32 m = 0;
01348
01349 <font class="keywordflow">do</font>
01350 {
01351 m++;
01352 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>+1)/2;
01353 h = (h+1)/2;
01354 <font class="keywordflow">if</font>(m==mipMap) <font class="keywordflow">return</font> h;
01355 }
01356 <font class="keywordflow">while</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>!=1 || h!=1);
01357
01358 <font class="keywordflow">return</font> 0;
01359 }
01360
01361
01362 <font class="comment">/*-------------------------------------------------------------------*\</font>
01363 <font class="comment"> getHeight</font>
01364 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01365"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a8">01365</a> uint32 CBitmap::getSize(uint32 numMipMap)<font class="keyword"> const</font>
01366 <font class="keyword"></font>{
01367 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>(numMipMap)*<a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>(numMipMap);
01368 }
01369
01370
01371
01372 <font class="comment">/*-------------------------------------------------------------------*\</font>
01373 <font class="comment"> buildMipMaps</font>
01374 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01375"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a11">01375</a> <font class="keywordtype">void</font> CBitmap::buildMipMaps()
01376 {
01377 uint32 i,j;
01378
01379 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>!=<a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>) <font class="keywordflow">return</font>;
01380 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>!=1) <font class="keywordflow">return</font>;
01381 <font class="keywordflow">if</font>(!<a class="code" href="namespaceNLMISC.html#a225">NLMISC::isPowerOf2</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>)) <font class="keywordflow">return</font>;
01382 <font class="keywordflow">if</font>(!<a class="code" href="namespaceNLMISC.html#a225">NLMISC::isPowerOf2</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>)) <font class="keywordflow">return</font>;
01383
01384 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
01385 uint32 h = <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
01386
01387 <font class="keywordflow">while</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>>1 || h>1)
01388 {
01389 uint32 precw = <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;
01390 uint32 prech = h;
01391 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>+1)/2;
01392 h = (h+1)/2;
01393 uint32 mulw= precw/<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;
01394 uint32 mulh= prech/h;
01395
01396 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>].resize(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h*4);
01397
01398
01399 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pRgba = (<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>*)&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>][0];
01400 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pRgbaPrev = (<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>*)&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>-1][0];
01401 <font class="keywordflow">for</font>(i=0; i<h; i++)
01402 {
01403 sint i0= mulh*i;
01404 sint i1= mulh*i+1;
01405 <font class="keywordflow">if</font>(mulh==1)
01406 i1=i0;
01407 i0*=precw;
01408 i1*=precw;
01409 <font class="keywordflow">for</font>(j=0; j<<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>; j++)
01410 {
01411 sint j0= mulw*j;
01412 sint j1= mulw*j+1;
01413 <font class="keywordflow">if</font>(mulh==1)
01414 j1=j0;
01415 CRGBA &c0= pRgbaPrev[i0+j0];
01416 CRGBA &c1= pRgbaPrev[i0+j1];
01417 CRGBA &c2= pRgbaPrev[i1+j0];
01418 CRGBA &c3= pRgbaPrev[i1+j1];
01419 pRgba[i*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + j].R = (c0.R +
01420 c1.R +
01421 c2.R +
01422 c3.R + 2 ) /4;
01423 pRgba[i*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + j].G = (c0.G +
01424 c1.G +
01425 c2.G +
01426 c3.G + 2 ) /4;
01427 pRgba[i*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + j].B = (c0.B +
01428 c1.B +
01429 c2.B +
01430 c3.B + 2 ) /4;
01431 pRgba[i*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + j].A = (c0.A +
01432 c1.A +
01433 c2.A +
01434 c3.A + 2 ) /4;
01435 }
01436 }
01437
01438 <a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>++;
01439 }
01440 }
01441
01442
01443 <font class="comment">/*-------------------------------------------------------------------*\</font>
01444 <font class="comment"> releaseMipMaps</font>
01445 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01446"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a12">01446</a> <font class="keywordtype">void</font> CBitmap::releaseMipMaps()
01447 {
01448 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a><=1) <font class="keywordflow">return</font>;
01449
01450 <a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>=1;
01451 <font class="keywordflow">for</font>(sint i=1;i<<a class="code" href="namespaceNLMISC.html#a4">MAX_MIPMAP</a>;i++)
01452 {
01453 <a class="code" href="namespaceNLMISC.html#a222">NLMISC::contReset</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[i]);
01454 }
01455 }
01456
01457
01458 <font class="comment">/*-------------------------------------------------------------------*\</font>
01459 <font class="comment"> resample</font>
01460 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01461"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a14">01461</a> <font class="keywordtype">void</font> CBitmap::resample(sint32 nNewWidth, sint32 nNewHeight)
01462 {
01463 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>);
01464 <font class="keywordtype">bool</font> needRebuild = <font class="keyword">false</font>;
01465
01466 <font class="comment">// Deleting mipmaps</font>
01467 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>>1)
01468 needRebuild = <font class="keyword">true</font>;
01469 <a class="code" href="classNLMISC_1_1CBitmap.html#a12">releaseMipMaps</a>();
01470
01471 <font class="keywordflow">if</font>(nNewWidth==0 || nNewHeight==0)
01472 {
01473 <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> = 0;
01474 <font class="keywordflow">return</font>;
01475 }
01476
01477 std::vector<uint8> pDestui;
01478 pDestui.resize(nNewWidth*nNewHeight*4);
01479 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pDestRgba = (<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>*)&pDestui[0];
01480
01481 <a class="code" href="classNLMISC_1_1CBitmap.html#c6">resamplePicture32</a> ((<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>*)&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][0], pDestRgba, <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>, <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>, nNewWidth, nNewHeight);
01482 <a class="code" href="namespaceNLMISC.html#a222">NLMISC::contReset</a>(_Data[0]); <font class="comment">// free memory</font>
01483 _Data[0] = pDestui;
01484 <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>= nNewWidth;
01485 <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>= nNewHeight;
01486
01487 <font class="comment">// Rebuilding mipmaps</font>
01488 <font class="keywordflow">if</font>(needRebuild)
01489 {
01490 <a class="code" href="classNLMISC_1_1CBitmap.html#a11">buildMipMaps</a>();
01491 }
01492 }
01493
01494
01495 <font class="comment">/*-------------------------------------------------------------------*\</font>
01496 <font class="comment"> resize</font>
01497 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01498"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a15">01498</a> <font class="keywordtype">void</font> CBitmap::resize (sint32 nNewWidth, sint32 nNewHeight, TType newType)
01499 {
01500 <font class="comment">// Deleting mipmaps</font>
01501 <a class="code" href="classNLMISC_1_1CBitmap.html#a12">releaseMipMaps</a>();
01502
01503 <font class="comment">// Change type of bitmap ?</font>
01504 <font class="keywordflow">if</font> (newType!=<a class="code" href="classNLMISC_1_1CBitmap.html#s11s10">DonTKnow</a>)
01505 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>=newType;
01506
01507 <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a> = nNewWidth;
01508 <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> = nNewHeight;
01509
01510 <font class="comment">// resize the level 0 only.</font>
01511 <a class="code" href="classNLMISC_1_1CBitmap.html#a16">resizeMipMap</a>(0, nNewWidth, nNewHeight);
01512 }
01513
01514
01515 <font class="comment">/*-------------------------------------------------------------------*\</font>
01516 <font class="comment"> resizeMipMap</font>
01517 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01518"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a16">01518</a> <font class="keywordtype">void</font> CBitmap::resizeMipMap (uint32 numMipMap, sint32 nNewWidth, sint32 nNewHeight)
01519 {
01520 <a class="code" href="debug_8h.html#a6">nlassert</a>(numMipMap<<a class="code" href="namespaceNLMISC.html#a4">MAX_MIPMAP</a>);
01521
01522 <font class="comment">// free memory</font>
01523 <a class="code" href="namespaceNLMISC.html#a222">NLMISC::contReset</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[numMipMap]);
01524
01525 <font class="comment">// DXTC compressed??</font>
01526 <font class="keywordtype">bool</font> isDXTC= <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>==<a class="code" href="classNLMISC_1_1CBitmap.html#s11s4">DXTC1</a> || <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>==<a class="code" href="classNLMISC_1_1CBitmap.html#s11s5">DXTC1Alpha</a> || <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>==<a class="code" href="classNLMISC_1_1CBitmap.html#s11s6">DXTC3</a> || <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>==<a class="code" href="classNLMISC_1_1CBitmap.html#s11s7">DXTC5</a>;
01527 <font class="comment">// if yes, must round up width and height to 4, for allocation</font>
01528 nNewWidth= 4*((nNewWidth+3)/4);
01529 nNewHeight= 4*((nNewHeight+3)/4);
01530
01531 <font class="comment">// resize the buffer</font>
01532 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[numMipMap].resize (((uint32)(nNewWidth*nNewHeight)*<a class="code" href="classNLMISC_1_1CBitmap.html#p0">bitPerPixels</a>[<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>])/8);
01533 }
01534
01535
01536 <font class="comment">/*-------------------------------------------------------------------*\</font>
01537 <font class="comment"> reset</font>
01538 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01539"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a17">01539</a> <font class="keywordtype">void</font> CBitmap::setMipMapCount(uint32 mmc)
01540 {
01541 <a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>= <a class="code" href="memory__common_8h.html#a7">uint8</a>(mmc);
01542 }
01543
01544
01545 <font class="comment">/*-------------------------------------------------------------------*\</font>
01546 <font class="comment"> reset</font>
01547 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01548"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a13">01548</a> <font class="keywordtype">void</font> CBitmap::reset(TType <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>)
01549 {
01550 <font class="keywordflow">for</font>(uint i=0; i<<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>; i++)
01551 {
01552 <a class="code" href="namespaceNLMISC.html#a222">NLMISC::contReset</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[i]);
01553 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[i].resize(0);
01554 }
01555 <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> = 0;
01556 <a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>= 1;
01557
01558 <font class="comment">// Change pixel format</font>
01559 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>=<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>;
01560 }
01561
01562
01563
01564 <font class="comment">/*-------------------------------------------------------------------*\</font>
01565 <font class="comment"> resamplePicture32</font>
01566 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01567"></a><a class="code" href="classNLMISC_1_1CBitmap.html#c6">01567</a> <font class="keywordtype">void</font> CBitmap::resamplePicture32 (<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pSrc, <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pDest,
01568 sint32 nSrcWidth, sint32 nSrcHeight,
01569 sint32 nDestWidth, sint32 nDestHeight)
01570 {
01571 <font class="keywordflow">if</font> ((nSrcWidth<=0)||(nSrcHeight<=0)||(nDestHeight<=0)||(nDestHeight<=0))
01572 <font class="keywordflow">return</font>;
01573 <font class="keywordtype">bool</font> bXMag=(nDestWidth>=nSrcWidth);
01574 <font class="keywordtype">bool</font> bYMag=(nDestHeight>=nSrcHeight);
01575 <font class="keywordtype">bool</font> bXEq=(nDestWidth==nSrcWidth);
01576 <font class="keywordtype">bool</font> bYEq=(nDestHeight==nSrcHeight);
01577 std::vector<NLMISC::CRGBAF> pIterm (nDestWidth*nSrcHeight);
01578
01579 <font class="keywordflow">if</font> (bXMag)
01580 {
01581 <font class="keywordtype">float</font> fXdelta=(float)(nSrcWidth)/(float)(nDestWidth);
01582 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> *pItermPtr=&*pIterm.begin();
01583 sint32 nY;
01584 <font class="keywordflow">for</font> (nY=0; nY<nSrcHeight; nY++)
01585 {
01586 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pSrcLine=pSrc;
01587 <font class="keywordtype">float</font> fX=0.f;
01588 sint32 nX;
01589 <font class="keywordflow">for</font> (nX=0; nX<nDestWidth; nX++)
01590 {
01591 <font class="keywordtype">float</font> fVirgule=fX-(float)floor(fX);
01592 <a class="code" href="debug_8h.html#a6">nlassert</a> (fVirgule>=0.f);
01593 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> vColor;
01594 <font class="keywordflow">if</font> (fVirgule>=0.5f)
01595 {
01596 <font class="keywordflow">if</font> (fX<(float)(nSrcWidth-1))
01597 {
01598 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> vColor1 (pSrcLine[(sint32)floor(fX)]);
01599 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> vColor2 (pSrcLine[(sint32)floor(fX)+1]);
01600 vColor=vColor1*(1.5f-fVirgule)+vColor2*(fVirgule-0.5f);
01601 }
01602 <font class="keywordflow">else</font>
01603 vColor=<a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> (pSrcLine[(sint32)floor(fX)]);
01604 }
01605 <font class="keywordflow">else</font>
01606 {
01607 <font class="keywordflow">if</font> (fX>=1.f)
01608 {
01609 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> vColor1 (pSrcLine[(sint32)floor(fX)]);
01610 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> vColor2 (pSrcLine[(sint32)floor(fX)-1]);
01611 vColor=vColor1*(0.5f+fVirgule)+vColor2*(0.5f-fVirgule);
01612 }
01613 <font class="keywordflow">else</font>
01614 vColor=<a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> (pSrcLine[(sint32)floor(fX)]);
01615 }
01616 *(pItermPtr++)=vColor;
01617 fX+=fXdelta;
01618 }
01619 pSrc+=nSrcWidth;
01620 }
01621 }
01622 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (bXEq)
01623 {
01624 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> *pItermPtr=&*pIterm.begin();
01625 <font class="keywordflow">for</font> (sint32 nY=0; nY<nSrcHeight; nY++)
01626 {
01627 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pSrcLine=pSrc;
01628 sint32 nX;
01629 <font class="keywordflow">for</font> (nX=0; nX<nDestWidth; nX++)
01630 *(pItermPtr++)=<a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> (pSrcLine[nX]);
01631 pSrc+=nSrcWidth;
01632 }
01633 }
01634 <font class="keywordflow">else</font>
01635 {
01636 <font class="keywordtype">double</font> fXdelta=(double)(nSrcWidth)/(double)(nDestWidth);
01637 <a class="code" href="debug_8h.html#a6">nlassert</a> (fXdelta>1.f);
01638 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> *pItermPtr=&*pIterm.begin();
01639 sint32 nY;
01640 <font class="keywordflow">for</font> (nY=0; nY<nSrcHeight; nY++)
01641 {
01642 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pSrcLine=pSrc;
01643 <font class="keywordtype">double</font> fX=0.f;
01644 sint32 nX;
01645 <font class="keywordflow">for</font> (nX=0; nX<nDestWidth; nX++)
01646 {
01647 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> vColor (0.f, 0.f, 0.f, 0.f);
01648 <font class="keywordtype">double</font> fFinal=fX+fXdelta;
01649 <font class="keywordflow">while</font> (fX<fFinal)
01650 {
01651 <font class="keywordtype">double</font> fNext=(double)floor (fX)+1.f;
01652 <font class="keywordflow">if</font> (fNext>fFinal)
01653 fNext=fFinal;
01654 vColor+=((float)(fNext-fX))*<a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> (pSrcLine[(sint32)floor(fX)]);
01655 fX=fNext;
01656 }
01657 <a class="code" href="debug_8h.html#a6">nlassert</a> (fX==fFinal);
01658 vColor/=(float)fXdelta;
01659 *(pItermPtr++)=vColor;
01660 }
01661 pSrc+=nSrcWidth;
01662 }
01663 }
01664
01665 <font class="keywordflow">if</font> (bYMag)
01666 {
01667 <font class="keywordtype">double</font> fYdelta=(double)(nSrcHeight)/(double)(nDestHeight);
01668 sint32 nX;
01669 <font class="keywordflow">for</font> (nX=0; nX<nDestWidth; nX++)
01670 {
01671 <font class="keywordtype">double</font> fY=0.f;
01672 sint32 nY;
01673 <font class="keywordflow">for</font> (nY=0; nY<nDestHeight; nY++)
01674 {
01675 <font class="keywordtype">double</font> fVirgule=fY-(double)floor(fY);
01676 <a class="code" href="debug_8h.html#a6">nlassert</a> (fVirgule>=0.f);
01677 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> vColor;
01678 <font class="keywordflow">if</font> (fVirgule>=0.5f)
01679 {
01680 <font class="keywordflow">if</font> (fY<(double)(nSrcHeight-1))
01681 {
01682 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> vColor1=pIterm[((sint32)floor(fY))*nDestWidth+nX];
01683 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> vColor2=pIterm[(((sint32)floor(fY))+1)*nDestWidth+nX];
01684 vColor=vColor1*(1.5f-(float)fVirgule)+vColor2*((float)fVirgule-0.5f);
01685 }
01686 <font class="keywordflow">else</font>
01687 vColor=pIterm[((sint32)floor(fY))*nDestWidth+nX];
01688 }
01689 <font class="keywordflow">else</font>
01690 {
01691 <font class="keywordflow">if</font> (fY>=1.f)
01692 {
01693 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> vColor1=pIterm[((sint32)floor(fY))*nDestWidth+nX];
01694 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> vColor2=pIterm[(((sint32)floor(fY))-1)*nDestWidth+nX];
01695 vColor=vColor1*(0.5f+(float)fVirgule)+vColor2*(0.5f-(float)fVirgule);
01696 }
01697 <font class="keywordflow">else</font>
01698 vColor=pIterm[((sint32)floor(fY))*nDestWidth+nX];
01699 }
01700 pDest[nX+nY*nDestWidth]=vColor;
01701 fY+=fYdelta;
01702 }
01703 }
01704 }
01705 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (bYEq)
01706 {
01707 <font class="keywordflow">for</font> (sint32 nX=0; nX<nDestWidth; nX++)
01708 {
01709 sint32 nY;
01710 <font class="keywordflow">for</font> (nY=0; nY<nDestHeight; nY++)
01711 {
01712 pDest[nX+nY*nDestWidth]=pIterm[nY*nDestWidth+nX];
01713 }
01714 }
01715 }
01716 <font class="keywordflow">else</font>
01717 {
01718 <font class="keywordtype">double</font> fYdelta=(double)(nSrcHeight)/(double)(nDestHeight);
01719 <a class="code" href="debug_8h.html#a6">nlassert</a> (fYdelta>1.f);
01720 sint32 nX;
01721 <font class="keywordflow">for</font> (nX=0; nX<nDestWidth; nX++)
01722 {
01723 <font class="keywordtype">double</font> fY=0.f;
01724 sint32 nY;
01725 <font class="keywordflow">for</font> (nY=0; nY<nDestHeight; nY++)
01726 {
01727 <a class="code" href="classNLMISC_1_1CRGBAF.html">NLMISC::CRGBAF</a> vColor (0.f, 0.f, 0.f, 0.f);
01728 <font class="keywordtype">double</font> fFinal=fY+fYdelta;
01729 <font class="keywordflow">while</font> ((fY<fFinal)&&((sint32)fY!=nSrcHeight))
01730 {
01731 <font class="keywordtype">double</font> fNext=(double)floor (fY)+1.f;
01732 <font class="keywordflow">if</font> (fNext>fFinal)
01733 fNext=fFinal;
01734 vColor+=((float)(fNext-fY))*pIterm[((sint32)floor(fY))*nDestWidth+nX];
01735 fY=fNext;
01736 }
01737 vColor/=(float)fYdelta;
01738 pDest[nX+nY*nDestWidth]=vColor;
01739 }
01740 }
01741 }
01742 }
01743
01744
01745
01746 <font class="comment">/*-------------------------------------------------------------------*\</font>
01747 <font class="comment"> readTGA</font>
01748 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l01749"></a><a class="code" href="classNLMISC_1_1CBitmap.html#c2">01749</a> uint8 CBitmap::readTGA( <a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f)
01750 {
01751 <font class="keywordflow">if</font>(!f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>()) <font class="keywordflow">return</font> 0;
01752
01753 uint32 size;
01754 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
01755 sint32 slsize;
01756 uint8 *scanline;
01757 uint8 <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>,g,b;
01758 sint32 i,j,k;
01759
01760 <font class="comment">// TGA file header fields</font>
01761 uint8 lengthID;
01762 uint8 cMapType;
01763 uint8 imageType;
01764 uint16 origin;
01765 uint16 length;
01766 uint8 <a class="code" href="driver__opengl__extension__def_8h.html#a391">depth</a>;
01767 uint16 xOrg;
01768 uint16 yOrg;
01769 uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;
01770 uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
01771 uint8 imageDepth;
01772 uint8 desc;
01773
01774 <font class="comment">// Image/Color map data</font>
01775 uint8 *imageID;
01776
01777
01778
01779 <font class="comment">// Determining whether file is in Original or New TGA format</font>
01780
01781 <font class="keywordtype">bool</font> newTgaFormat;
01782 uint32 extAreaOffset;
01783 uint32 devDirectoryOffset;
01784 <font class="keywordtype">char</font> signature[16];
01785
01786 f.<a class="code" href="classNLMISC_1_1IStream.html#a31">seek</a> (0, f.<a class="code" href="classNLMISC_1_1IStream.html#s3s2">end</a>);
01787 newTgaFormat = <font class="keyword">false</font>;
01788 <font class="keywordflow">if</font> (f.<a class="code" href="classNLMISC_1_1IStream.html#a32">getPos</a>() >= 26)
01789 {
01790 f.<a class="code" href="classNLMISC_1_1IStream.html#a31">seek</a> (-26, f.<a class="code" href="classNLMISC_1_1IStream.html#s3s2">end</a>);
01791 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(extAreaOffset);
01792 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(devDirectoryOffset);
01793 <font class="keywordflow">for</font>(i=0; i<16; i++)
01794 {
01795 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(signature[i]);
01796 }
01797 <font class="keywordflow">if</font>(strncmp(signature,<font class="stringliteral">"TRUEVISION-XFILE"</font>,16)==0)
01798 newTgaFormat = <font class="keyword">true</font>;
01799 }
01800
01801
01802
01803 <font class="comment">// Reading TGA file header</font>
01804 f.<a class="code" href="classNLMISC_1_1IStream.html#a31">seek</a> (0, f.<a class="code" href="classNLMISC_1_1IStream.html#s3s0">begin</a>);
01805
01806 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(lengthID);
01807 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(cMapType);
01808 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(imageType);
01809 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(origin);
01810 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(length);
01811 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a391">depth</a>);
01812 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(xOrg);
01813 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(yOrg);
01814 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>);
01815 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>);
01816 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(imageDepth);
01817 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(desc);
01818
01819 <font class="keywordflow">if</font>(cMapType!=0)
01820 {
01821 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"readTga : color-map not supported"</font>);
01822 }
01823
01824 <font class="keywordflow">if</font>(lengthID>0)
01825 {
01826 imageID = <font class="keyword">new</font> uint8[lengthID];
01827 <font class="keywordflow">for</font>(i=0; i<lengthID; i++)
01828 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(imageID[i]);
01829 }
01830
01831
01832
01833 <font class="comment">// Reading TGA image data</font>
01834
01835 <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;
01836 <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
01837 size = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a> * <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> * (imageDepth/8);
01838
01839 <font class="keywordflow">switch</font>(imageType)
01840 {
01841 <font class="comment">// Uncompressed RGB or RGBA</font>
01842 <font class="keywordflow">case</font> 2:
01843 {
01844 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].resize(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>*4);
01845 uint8 upSideDown = ((desc & (1 << 5))==0);
01846 slsize = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a> * imageDepth / 8;
01847
01848 scanline = <font class="keyword">new</font> uint8[slsize];
01849 <font class="keywordflow">if</font>(!scanline)
01850 {
01851 <font class="keywordflow">throw</font> EAllocationFailure();
01852 }
01853
01854 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a><<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
01855 {
01856 <font class="comment">// Serial buffer: more efficient way to load.</font>
01857 f.<a class="code" href="classNLMISC_1_1IStream.html#z327_0">serialBuffer</a> (scanline, slsize);
01858
01859 <font class="keywordflow">if</font>(imageDepth==24 || imageDepth==32)
01860 {
01861 sint32 mult = 3;
01862 <font class="keywordflow">if</font>(imageDepth==16)
01863 {
01864 mult = 2;
01865 }
01866 <font class="keywordflow">if</font>(imageDepth==32)
01867 {
01868 mult = 4;
01869 }
01870 <font class="keywordflow">if</font>(imageDepth!=16)
01871 {
01872 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a><<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
01873 {
01874 <font class="comment">// RGB(A)</font>
01875 <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> = scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*mult+0];
01876 g = scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*mult+1];
01877 b = scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*mult+2];
01878 <font class="comment">// Switching to BGR(A)</font>
01879 scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*mult+0] = b;
01880 scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*mult+1] = g;
01881 scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*mult+2] = <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>;
01882 }
01883 }
01884 }
01885
01886 k=0;
01887 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>; i++)
01888 {
01889 <font class="keywordflow">if</font>(upSideDown)
01890 {
01891 <font class="keywordflow">if</font>(imageDepth==16)
01892 {
01893 uint16 <a class="code" href="namespaceNLMISC.html#a294">toto</a> = (uint16)scanline[k++];
01894 <a class="code" href="namespaceNLMISC.html#a294">toto</a> |= scanline[k++]<<8;
01895 uint <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> = <a class="code" href="namespaceNLMISC.html#a294">toto</a>>>10;
01896 uint g = (<a class="code" href="namespaceNLMISC.html#a294">toto</a>>>5)&0x1f;
01897 uint b = <a class="code" href="namespaceNLMISC.html#a294">toto</a>&0x1f;
01898 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i] = (r<<3) | (r>>2);
01899 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 1] = (g<<3) | (g>>2);
01900 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 2] = (b<<3) | (b>>2);
01901 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 3] = 255;
01902 }
01903 <font class="keywordflow">else</font>
01904 {
01905 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i] = scanline[k++];
01906 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 1] = scanline[k++];
01907 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 2] = scanline[k++];
01908 <font class="keywordflow">if</font>(imageDepth==32)
01909 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 3] = scanline[k++];
01910 <font class="keywordflow">else</font>
01911 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 3] = 255;
01912 }
01913 }
01914 <font class="keywordflow">else</font>
01915 {
01916 <font class="keywordflow">if</font>(imageDepth==16)
01917 {
01918 uint16 <a class="code" href="namespaceNLMISC.html#a294">toto</a> = (uint16)scanline[k++];
01919 <a class="code" href="namespaceNLMISC.html#a294">toto</a> |= scanline[k++]<<8;
01920 <font class="keywordtype">int</font> <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> = <a class="code" href="namespaceNLMISC.html#a294">toto</a>>>10;
01921 <font class="keywordtype">int</font> g = <a class="code" href="namespaceNLMISC.html#a294">toto</a>&(0x3e0)>>5;
01922 <font class="keywordtype">int</font> b = <a class="code" href="namespaceNLMISC.html#a294">toto</a>&0x1f;
01923 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i] = (r<<3) | (r>>2);
01924 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 1] = (g<<3) | (g>>2);
01925 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 2] = (b<<3) | (b>>2);
01926 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 3] = 255;
01927 }
01928 <font class="keywordflow">else</font>
01929 {
01930 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i] = scanline[k++];
01931 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 1] = scanline[k++];
01932 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 2] = scanline[k++];
01933 <font class="keywordflow">if</font>(imageDepth==32)
01934 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 3] = scanline[k++];
01935 <font class="keywordflow">else</font>
01936 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + 4*i + 3] = 255;
01937 }
01938 }
01939 }
01940 }
01941
01942 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>;
01943 <font class="keyword">delete</font> scanline;
01944 };
01945 <font class="keywordflow">break</font>;
01946
01947 <font class="comment">// Uncompressed Grayscale bitmap</font>
01948 <font class="keywordflow">case</font> 3:
01949 {
01950 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].resize(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>);
01951 uint8 upSideDown = ((desc & (1 << 5))==0);
01952 slsize = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
01953
01954 scanline = <font class="keyword">new</font> uint8[slsize];
01955 <font class="keywordflow">if</font>(!scanline)
01956 {
01957 <font class="keywordflow">throw</font> EAllocationFailure();
01958 }
01959
01960 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a><<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
01961 {
01962 <font class="comment">// Serial buffer: more efficient way to load.</font>
01963 f.<a class="code" href="classNLMISC_1_1IStream.html#z327_0">serialBuffer</a> (scanline, slsize);
01964
01965 k=0;
01966 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>; i++)
01967 {
01968 <font class="keywordflow">if</font>(upSideDown)
01969 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> + i] = scanline[k++];
01970 <font class="keywordflow">else</font>
01971 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> + i] = scanline[k++];
01972 }
01973 }
01974
01975 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#n2">_LoadGrayscaleAsAlpha</a>?<a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>:<a class="code" href="classNLMISC_1_1CBitmap.html#s11s1">Luminance</a>;
01976 <font class="keyword">delete</font> scanline;
01977 };
01978 <font class="keywordflow">break</font>;
01979
01980 <font class="comment">// Compressed RGB or RGBA</font>
01981 <font class="keywordflow">case</font> 10:
01982 {
01983 uint8 packet;
01984 uint8 pixel[4];
01985 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a393">imageSize</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
01986 uint32 readSize = 0;
01987 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>*4);
01988
01989 <font class="keywordflow">while</font>(readSize < <a class="code" href="driver__opengl__extension__def_8h.html#a393">imageSize</a>)
01990 {
01991 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(packet);
01992 <font class="keywordflow">if</font>((packet & 0x80) > 0) <font class="comment">// packet RLE </font>
01993 {
01994 <font class="keywordflow">for</font>(i=0; i<imageDepth/8; i++)
01995 {
01996 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(pixel[i]);
01997 }
01998 <font class="keywordflow">for</font> (i=0; i < (packet & 0x7F) + 1; i++)
01999 {
02000 <font class="keywordflow">for</font>(j=0; j<imageDepth/8; j++)
02001 {
02002 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].push_back(pixel[j]);
02003 }
02004 <font class="keywordflow">if</font>(imageDepth==24)
02005 {
02006 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].push_back(0);
02007 }
02008 }
02009 }
02010 <font class="keywordflow">else</font> <font class="comment">// packet Raw </font>
02011 {
02012 <font class="keywordflow">for</font>(i=0; i<((packet & 0x7F) + 1); i++)
02013 {
02014 <font class="keywordflow">for</font>(j=0; j<imageDepth/8; j++)
02015 {
02016 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(pixel[j]);
02017 }
02018 <font class="keywordflow">if</font>(imageDepth==32)
02019 {
02020 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].push_back(pixel[2]);
02021 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].push_back(pixel[1]);
02022 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].push_back(pixel[0]);
02023 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].push_back(pixel[3]);
02024 }
02025 <font class="keywordflow">if</font>(imageDepth==24)
02026 {
02027 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].push_back(pixel[2]);
02028 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].push_back(pixel[1]);
02029 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].push_back(pixel[0]);
02030 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].push_back(0);
02031 }
02032 }
02033 }
02034 readSize += (packet & 0x7F) + 1;
02035 }
02036 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>;
02037 };
02038 <font class="keywordflow">break</font>;
02039
02040 <font class="comment">// Compressed Grayscale bitmap (not tested)</font>
02041 <font class="keywordflow">case</font> 11:
02042 {
02043 uint8 packet;
02044 uint8 pixel[4];
02045 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a393">imageSize</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
02046 uint32 readSize = 0;
02047 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].reserve(<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>*<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>);
02048
02049 <font class="keywordflow">while</font>(readSize < <a class="code" href="driver__opengl__extension__def_8h.html#a393">imageSize</a>)
02050 {
02051 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(packet);
02052 <font class="keywordflow">if</font>((packet & 0x80) > 0) <font class="comment">// packet RLE </font>
02053 {
02054 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(pixel[0]);
02055 <font class="keywordflow">for</font> (i=0; i < (packet & 0x7F) + 1; i++)
02056 {
02057 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].push_back(pixel[0]);
02058 }
02059 }
02060 <font class="keywordflow">else</font> <font class="comment">// packet Raw </font>
02061 {
02062 <font class="keywordflow">for</font>(i=0; i<((packet & 0x7F) + 1); i++)
02063 {
02064 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(pixel[0]);
02065 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0].push_back(pixel[0]);
02066 }
02067 }
02068 readSize += (packet & 0x7F) + 1;
02069 }
02070 <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#n2">_LoadGrayscaleAsAlpha</a>?<a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>:<a class="code" href="classNLMISC_1_1CBitmap.html#s11s1">Luminance</a>;
02071 };
02072 <font class="keywordflow">break</font>;
02073
02074 <font class="keywordflow">default</font>:
02075 <font class="keywordflow">return</font> 0;
02076 }
02077
02078 <a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a> = 1;
02079 <font class="keywordflow">return</font>(imageDepth);
02080
02081 }
02082
02083 <font class="comment">/*-------------------------------------------------------------------*\</font>
02084 <font class="comment"> writeTGA</font>
02085 <font class="comment">\*-------------------------------------------------------------------*/</font>
<a name="l02086"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a18">02086</a> <font class="keywordtype">bool</font> CBitmap::writeTGA( <a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f, uint32 d, <font class="keywordtype">bool</font> upsideDown)
02087 {
02088 <font class="keywordflow">if</font>(f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>()) <font class="keywordflow">return</font> <font class="keyword">false</font>;
02089 <font class="keywordflow">if</font>(d!=24 && d!=32 && d!=16 && d!=8) <font class="keywordflow">return</font> <font class="keyword">false</font>;
02090 <font class="keywordflow">if</font> ((<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> != <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>)&&(<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> != <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>)) <font class="keywordflow">return</font> <font class="keyword">false</font>;
02091 <font class="keywordflow">if</font> ((<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>) && (d != 8)) <font class="keywordflow">return</font> <font class="keyword">false</font>;
02092
02093 sint32 i,j,<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
02094 uint8 * scanline;
02095 uint8 <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>,g,b,a;
02096
02097 uint8 lengthID = 0;
02098 uint8 cMapType = 0;
02099 uint8 imageType = 2;
02100 uint16 origin = 0;
02101 uint16 length = 0;
02102 uint8 <a class="code" href="driver__opengl__extension__def_8h.html#a391">depth</a> = 0;
02103 uint16 xOrg = 0;
02104 uint16 yOrg = 0;
02105 uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> = (uint16)<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
02106 uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> = (uint16)<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
02107 uint8 imageDepth = (uint8)d;
02108 uint8 desc = 0;
02109 <font class="keywordflow">if</font> (upsideDown)
02110 desc |= 1<<5;
02111
02112 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>)
02113 imageType = 3; <font class="comment">// Uncompressed grayscale</font>
02114
02115 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(lengthID);
02116 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(cMapType);
02117 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(imageType);
02118 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(origin);
02119 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(length);
02120 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a391">depth</a>);
02121 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(xOrg);
02122 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(yOrg);
02123 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>);
02124 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>);
02125 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(imageDepth);
02126 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(desc);
02127
02128 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>)
02129 scanline = <font class="keyword">new</font> uint8[<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>];
02130 <font class="keywordflow">else</font>
02131 scanline = <font class="keyword">new</font> uint8[<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4];
02132 <font class="keywordflow">if</font>(!scanline)
02133 {
02134 <font class="keywordflow">throw</font> EAllocationFailure();
02135 }
02136
02137 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a><(sint32)<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
02138 {
02139
02140 uint32 k=0;
02141 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>)
02142 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>; ++i) <font class="comment">// Alpha</font>
02143 {
02144 scanline[k++] = <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> + i];
02145 }
02146 <font class="keywordflow">else</font>
02147 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4; i+=4) <font class="comment">// 4:RGBA</font>
02148 {
02149 <font class="keywordflow">if</font>(d==16)
02150 {
02151 <font class="keywordflow">for</font>(j=0; j<(sint32)4; j++)
02152 {
02153 scanline[k++] = <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + i + j];
02154 }
02155 }
02156 <font class="keywordflow">else</font>
02157 {
02158 <font class="keywordflow">for</font>(j=0; j<(sint32)d/8; j++)
02159 {
02160 scanline[k++] = <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-1)*<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*4 + i + j];
02161 }
02162 }
02163 }
02164
02165 <font class="keywordflow">if</font>(d==16)
02166 {
02167 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a><(sint32)<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
02168 {
02169 <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> = scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*4+0];
02170 g = scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*4+1];
02171 b = scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*4+2];
02172 <font class="keywordtype">int</font> rr = <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> >>3;
02173 <font class="keywordtype">int</font> gg = g >>3;
02174 <font class="keywordtype">int</font> bb = b >>3;
02175 uint16 c16 = (rr<<10) | (gg<<5) | bb;
02176 scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*2+0] = c16&0xff;
02177 scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*2+1] = c16>>8;
02178 }
02179 }
02180 <font class="keywordflow">if</font>(d==24)
02181 {
02182 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a><(sint32)<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
02183 {
02184 <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> = scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*3+0];
02185 g = scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*3+1];
02186 b = scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*3+2];
02187 scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*3+0] = b;
02188 scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*3+1] = g;
02189 scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*3+2] = <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>;
02190 }
02191 }
02192 <font class="keywordflow">if</font>(d==32)
02193 {
02194 <font class="keywordflow">for</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a><(sint32)<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
02195 {
02196 <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> = scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*4+0];
02197 g = scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*4+1];
02198 b = scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*4+2];
02199 a= scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*4+3];
02200 scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*4+0] = b;
02201 scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*4+1] = g;
02202 scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*4+2] = <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>;
02203 scanline[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*4+3] = a;
02204 }
02205 }
02206
02207 <font class="keywordtype">int</font> finaleSize=<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*d/8;
02208 <font class="keywordflow">for</font>(i=0; i<finaleSize; i++)
02209 {
02210 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(scanline[i]);
02211 }
02212 }
02213 <font class="keyword">delete</font> scanline;
02214 <font class="keywordflow">return</font> <font class="keyword">true</font>;
02215 }
02216
02217 <font class="keyword">template</font><<font class="keyword">class</font> T>
02218 <font class="keywordtype">void</font> <a class="code" href="namespaceNLMISC.html#a287">rotateCCW</a> (<font class="keyword">const</font> T* <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, T* dst, uint srcWidth, uint srcHeight)
02219 {
02220 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a><srcHeight; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
02221 <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a><srcWidth; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
02222 {
02223 uint dstX=<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
02224 uint dstY=srcWidth-<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>-1;
02225 dst[dstX+dstY*srcHeight]=<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*srcWidth];
02226 }
02227 }
02228
02229 <font class="comment">/*template<class T></font>
02230 <font class="comment">void rotateCCW (const vector<T>& src, vector<T>& dst, uint srcWidth, uint srcHeight)</font>
02231 <font class="comment">{</font>
02232 <font class="comment"> for (uint y=0; y<srcHeight; y++)</font>
02233 <font class="comment"> for (uint x=0; x<srcWidth; x++)</font>
02234 <font class="comment"> {</font>
02235 <font class="comment"> uint dstX=y;</font>
02236 <font class="comment"> uint dstY=srcWidth-x;</font>
02237 <font class="comment"> dst[dstX+dstY*srcHeight]=src[x+y*srcWidth];</font>
02238 <font class="comment"> }</font>
02239 <font class="comment">}</font>
02240 <font class="comment">*/</font>
<a name="l02241"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a10">02241</a> <font class="keywordtype">void</font> CBitmap::rotateCCW()
02242 {
02243 <font class="comment">// Copy the array</font>
02244 std::vector<uint8> copy=<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0];
02245
02246 <font class="keywordflow">switch</font> (PixelFormat)
02247 {
02248 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>:
02249 <a class="code" href="namespaceNLMISC.html#a287">NLMISC::rotateCCW</a> ((uint32*)&(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][0]), (uint32*)&(copy[0]), <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>, <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>);
02250 <font class="keywordflow">break</font>;
02251 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s1">Luminance</a>:
02252 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>:
02253 <a class="code" href="namespaceNLMISC.html#a287">NLMISC::rotateCCW</a> (&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][0], &copy[0], <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>, <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>);
02254 <font class="keywordflow">break</font>;
02255 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s3">AlphaLuminance</a>:
02256 <a class="code" href="namespaceNLMISC.html#a287">NLMISC::rotateCCW</a> ((uint16*)&(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][0]), (uint16*)&(copy[0]), <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>, <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>);;
02257 <font class="keywordflow">break</font>;
02258 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
02259 }
02260
02261 uint32 tmp=<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
02262 <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>=<a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
02263 <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>=tmp;
02264 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0]=copy;
02265 }
02266
<a name="l02267"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a22">02267</a> <font class="keywordtype">bool</font> CBitmap::blit(<font class="keyword">const</font> CBitmap *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, sint32 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint32 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>)
02268 {
02269
02270 <a class="code" href="debug_8h.html#a6">nlassert</a>(this->PixelFormat == <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>->PixelFormat);
02271 <font class="keywordflow">if</font> (this-><a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> != <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>->PixelFormat)
02272 {
02273 <font class="keywordflow">return</font> <font class="keyword">false</font>;
02274 }
02275
02276
02277 <font class="comment">// check for dxtc use</font>
02278
02279 <font class="keyword">const</font> <font class="keywordtype">bool</font> useDXTC = <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s4">DXTC1</a> || <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s5">DXTC1Alpha</a> || <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s6">DXTC3</a> || <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s7">DXTC5</a>;
02280
02281 <font class="comment">// number of bits for a 4x4 pix block</font>
02282 <font class="keyword">const</font> uint dxtcNumBits = <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s4">DXTC1</a> || <a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s5">DXTC1Alpha</a> ? 64 : 128;
02283
02284
02285 <font class="keywordflow">if</font> (useDXTC)
02286 {
02287 <font class="comment">// blit pos must be multiple of 4</font>
02288
02289 <a class="code" href="debug_8h.html#a6">nlassert</a>(! (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> & 3 || <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> & 3) );
02290 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> & 3 || <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> & 3) <font class="keywordflow">return</font> <font class="keyword">false</font>;
02291
02292 }
02293
02294 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> != <a class="code" href="classNLMISC_1_1CBitmap.html#s11s10">DonTKnow</a>);
02295
02296 <font class="comment">// the width to copy</font>
02297 sint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>->_Width;
02298 <font class="comment">// the height to copy</font>
02299 sint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>->_Height;
02300
02301 uint destStartX, destStartY;
02302 uint srcStartX, srcStartY;
02303
02304
02305 <font class="comment">// clip against left</font>
02306 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> < 0)
02307 {
02308 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> += <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
02309 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> <= 0) <font class="keywordflow">return</font> <font class="keyword">true</font>;
02310 destStartX = 0;
02311 srcStartX = -<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
02312 }
02313 <font class="keywordflow">else</font>
02314 {
02315 destStartX = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
02316 srcStartX = 0;
02317 }
02318
02319 <font class="comment">// clip against top</font>
02320 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> < 0)
02321 {
02322 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> += <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
02323 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> <= 0) <font class="keywordflow">return</font> <font class="keyword">true</font>;
02324 srcStartY = -<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
02325 destStartY = 0;
02326 }
02327 <font class="keywordflow">else</font>
02328 {
02329 destStartY = <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
02330 srcStartY = 0;
02331 }
02332
02333 <font class="comment">// clip against right</font>
02334 <font class="keywordflow">if</font> ((destStartX + <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> - 1) >= <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>)
02335 {
02336 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a> - destStartX;
02337 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> <= 0) <font class="keywordflow">return</font> <font class="keyword">true</font>;
02338 }
02339
02340 <font class="comment">// clip against bottom</font>
02341 <font class="keywordflow">if</font> ((destStartY + <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> - 1) >= <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>)
02342 {
02343 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> - destStartY;
02344 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> <= 0) <font class="keywordflow">return</font> <font class="keyword">true</font>;
02345 }
02346
02347
02348 <font class="comment">// divide all distance by 4 when using DXTC</font>
02349 <font class="keywordflow">if</font> (useDXTC)
02350 {
02351 destStartX >>= 2;
02352 destStartY >>= 2;
02353 srcStartX >>= 2;
02354 srcStartY >>= 2;
02355 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> >>= 2;
02356 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> >>= 2;
02357 }
02358
02359
02360 <font class="comment">// bytes per pixs is for either one pixel or 16 (a 4x4 block in DXTC)</font>
02361 <font class="keyword">const</font> uint bytePerPixs = ( useDXTC ? dxtcNumBits : <a class="code" href="classNLMISC_1_1CBitmap.html#p0">bitPerPixels</a>[<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>] ) >> 3 <font class="comment">/* divide by 8 to get the number of bytes */</font>;
02362
02363
02364 <font class="keyword">const</font> uint destRealWidth = useDXTC ? (<a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a> >> 2) : <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
02365 <font class="keyword">const</font> uint srcRealWidth = useDXTC ? (<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>->_Width >> 2) : <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>->_Width;
02366
02367
02368 <font class="comment">// size to go to the next line in the destination</font>
02369 <font class="keyword">const</font> uint destStride = destRealWidth * bytePerPixs;
02370
02371 <font class="comment">// size to go to the next line in the source</font>
02372 <font class="keyword">const</font> uint srcStride = srcRealWidth * bytePerPixs;
02373
02374 <font class="comment">// length in bytes of a line to copy</font>
02375 <font class="keyword">const</font> uint lineLength = <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> * bytePerPixs;
02376
02377
02378 uint8 *destPos = &(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][0]) + destStride * destStartY + bytePerPixs * destStartX;
02379 <font class="keyword">const</font> uint8 *srcPos = &(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>->_Data[0][0]) + srcStride * srcStartY + bytePerPixs * srcStartX;
02380
02381 <font class="comment">// copy each hline</font>
02382 <font class="keywordflow">for</font> (sint k = 0; k < <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>; ++k)
02383 {
02384 ::memcpy(destPos, srcPos, lineLength);
02385 destPos += destStride;
02386 srcPos += srcStride;
02387 }
02388
02389
02390 <font class="keywordflow">return</font> <font class="keyword">true</font>;
02391 }
02392
02393 <font class="comment">// Private :</font>
<a name="l02394"></a><a class="code" href="classNLMISC_1_1CBitmap.html#c7">02394</a> <font class="keywordtype">float</font> CBitmap::getColorInterp (<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <font class="keywordtype">float</font> colorInXY00, <font class="keywordtype">float</font> colorInXY10, <font class="keywordtype">float</font> colorInXY01, <font class="keywordtype">float</font> colorInXY11)<font class="keyword"> const</font>
02395 <font class="keyword"></font>{
02396 <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a> = colorInXY00*(1.0f-<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>)*(1.0f-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>) +
02397 colorInXY10*( x)*(1.0f-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>) +
02398 colorInXY01*(1.0f-<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>)*( y) +
02399 colorInXY11*( x)*( y);
02400 <a class="code" href="namespaceNLMISC.html#a215">clamp</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>, 0.0f, 255.0f);
02401 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a>;
02402 }
02403
02404 <font class="comment">// Public:</font>
<a name="l02405"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a23">02405</a> CRGBAF CBitmap::getColor (<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>)<font class="keyword"> const</font>
02406 <font class="keyword"></font>{
02407 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> < 0.0f) <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = 0.0f;
02408 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> > 1.0f) <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = 1.0f;
02409 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> < 0.0f) <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> = 0.0f;
02410 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> > 1.0f) <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> = 1.0f;
02411
02412 sint32 nWidth = <a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>(0);
02413 sint32 nHeight = <a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>(0);
02414
02415 <font class="keywordflow">if</font> (nWidth == 0 || nHeight == 0) <font class="keywordflow">return</font> CRGBAF(0, 0, 0, 0);
02416
02417 <font class="keyword">const</font> std::vector<uint8> &rBitmap = <a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>(0);
02418 sint32 nX[4], nY[4];
02419
02420 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> *= nWidth-1;
02421 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> *= nHeight-1;
02422
02423 <font class="comment">// Integer part of (x,y)</font>
02424 <font class="comment">//nX[0] = ((sint32)floor(x-0.5f));</font>
02425 <font class="comment">//nY[0] = ((sint32)floor(y-0.5f));</font>
02426 nX[0] = ((sint32)floor(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>));
02427 nY[0] = ((sint32)floor(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>));
02428
02429 nX[1] = (nX[0] < (nWidth-1) ? nX[0]+1 : nX[0]);
02430 nY[1] = nY[0];
02431
02432 nX[2] = nX[0];
02433 nY[2] = (nY[0] < (nHeight-1) ? nY[0]+1 : nY[0]);
02434
02435 nX[3] = nX[1];
02436 nY[3] = nY[2];
02437
02438 uint32 i;
02439
02440 <font class="keywordflow">for</font> (i = 0; i < 4; ++i)
02441 {
02442 <a class="code" href="debug_8h.html#a6">nlassert</a> (nX[i] >= 0);
02443 <a class="code" href="debug_8h.html#a6">nlassert</a> (nY[i] >= 0 );
02444 <a class="code" href="debug_8h.html#a6">nlassert</a> (nX[i] < nWidth);
02445 <a class="code" href="debug_8h.html#a6">nlassert</a> (nY[i] < nHeight);
02446 }
02447
02448 <font class="comment">// Decimal part of (x,y)</font>
02449 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - (float)nX[0];
02450 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - (float)nY[0];
02451
02452 <font class="keywordflow">switch</font> (this-><a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a>)
02453 {
02454 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>:
02455 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s4">DXTC1</a>:
02456 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s5">DXTC1Alpha</a>:
02457 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s6">DXTC3</a>:
02458 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s7">DXTC5</a>:
02459 {
02460 CRGBAF finalVal;
02461 CRGBA val[4];
02462
02463 <font class="keywordflow">if</font> (this-><a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>)
02464 {
02465 <font class="keywordflow">for</font> (i = 0; i < 4; ++i)
02466 {
02467 val[i] = CRGBA (rBitmap[(nX[i]+nY[i]*nWidth)*4+0],
02468 rBitmap[(nX[i]+nY[i]*nWidth)*4+1],
02469 rBitmap[(nX[i]+nY[i]*nWidth)*4+2],
02470 rBitmap[(nX[i]+nY[i]*nWidth)*4+3]);
02471 }
02472 }
02473 <font class="keywordflow">else</font>
02474 {
02475 <font class="comment">// slower version : get from DXT</font>
02476 <font class="keywordflow">for</font> (i = 0; i < 4; ++i)
02477 {
02478 val[i] = <a class="code" href="classNLMISC_1_1CBitmap.html#a24">getPixelColor</a>(nX[i], nY[i]);
02479 }
02480 }
02481
02482 finalVal.R = <a class="code" href="classNLMISC_1_1CBitmap.html#c7">getColorInterp</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, val[0].R, val[1].R, val[2].R, val[3].R);
02483 finalVal.G = <a class="code" href="classNLMISC_1_1CBitmap.html#c7">getColorInterp</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, val[0].G, val[1].G, val[2].G, val[3].G);
02484 finalVal.B = <a class="code" href="classNLMISC_1_1CBitmap.html#c7">getColorInterp</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, val[0].B, val[1].B, val[2].B, val[3].B);
02485 finalVal.A = <a class="code" href="classNLMISC_1_1CBitmap.html#c7">getColorInterp</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, val[0].A, val[1].A, val[2].A, val[3].A);
02486
02487 <font class="keywordflow">return</font> finalVal;
02488 }
02489 <font class="keywordflow">break</font>;
02490 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>:
02491 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s1">Luminance</a>:
02492 {
02493
02494 <font class="keywordtype">float</font> finalVal;
02495 <font class="keywordtype">float</font> val[4];
02496
02497 <font class="keywordflow">for</font> (i = 0; i < 4; ++i)
02498 val[i] = rBitmap[(nX[i]+nY[i]*nWidth)];
02499
02500 finalVal = <a class="code" href="classNLMISC_1_1CBitmap.html#c7">getColorInterp</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, val[0], val[1], val[2], val[3]);
02501
02502 <font class="keywordflow">if</font> (this-><a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> == <a class="code" href="classNLMISC_1_1CBitmap.html#s11s2">Alpha</a>)
02503 <font class="keywordflow">return</font> CRGBAF (255.0f, 255.0f, 255.0f, finalVal);
02504 <font class="keywordflow">else</font> <font class="comment">// Luminance</font>
02505 <font class="keywordflow">return</font> CRGBAF (finalVal, finalVal, finalVal, 255.0f);
02506 }
02507 <font class="keywordflow">break</font>;
02508 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
02509 }
02510
02511 <font class="keywordflow">return</font> CRGBAF (0.0f, 0.0f, 0.0f, 0.0f);
02512 }
02513
02514
<a name="l02515"></a><a class="code" href="classNLMISC_1_1CBitmap.html#d0">02515</a> <font class="keywordtype">void</font> CBitmap::loadSize(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f, uint32 &retWidth, uint32 &retHeight)
02516 {
02517 retWidth= 0;
02518 retHeight= 0;
02519
02520
02521 <a class="code" href="debug_8h.html#a6">nlassert</a>(f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>());
02522
02523 <font class="comment">// testing if DDS</font>
02524 uint32 fileType = 0;
02525 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(fileType);
02526 <font class="keywordflow">if</font>(fileType == <a class="code" href="namespaceNLMISC.html#a2">DDS</a>)
02527 {
02528 <font class="comment">// read entire DDS header.</font>
02529 uint32 size = 0;
02530 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(size); <font class="comment">// size in Bytes of header(without "DDS")</font>
02531 uint32 * _DDSSurfaceDesc = <font class="keyword">new</font> uint32[size];
02532 std::auto_ptr<uint32> _DDSSurfaceDescAuto(_DDSSurfaceDesc);
02533 _DDSSurfaceDesc[0]= size;
02534
02535 <font class="keywordflow">for</font>(uint i= 0; i<size/4 - 1; i++)
02536 {
02537 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(_DDSSurfaceDesc[i+1]);
02538 }
02539
02540 <font class="comment">// flags determines which members of the header structure contain valid data</font>
02541 uint32 flags = _DDSSurfaceDesc[1];
02542
02543 <font class="comment">//verify if file have linearsize set</font>
02544 <font class="keywordflow">if</font>(!(flags & <a class="code" href="bitmap_8h.html#a1">DDSD_LINEARSIZE</a>))
02545 {
02546 <font class="keywordflow">throw</font> EDDSBadHeader();
02547 }
02548
02549 <font class="comment">//-------------- extracting and testing useful info</font>
02550 retWidth = _DDSSurfaceDesc[2];
02551 retHeight = _DDSSurfaceDesc[3];
02552 }
02553 <font class="comment">// assuming it's TGA</font>
02554 <font class="keywordflow">else</font>
02555 {
02556 <font class="keywordflow">if</font>(!f.<a class="code" href="classNLMISC_1_1IStream.html#a31">seek</a> (0, <a class="code" href="classNLMISC_1_1IStream.html#s3s0">NLMISC::IStream::begin</a>))
02557 {
02558 <font class="keywordflow">throw</font> ESeekFailed();
02559 }
02560
02561 <font class="comment">// Reading header, </font>
02562 <font class="comment">// To make sure that the bitmap is TGA, we check imageType and imageDepth.</font>
02563 uint8 lengthID;
02564 uint8 cMapType;
02565 uint8 imageType;
02566 uint16 tgaOrigin;
02567 uint16 length;
02568 uint8 <a class="code" href="driver__opengl__extension__def_8h.html#a391">depth</a>;
02569 uint16 xOrg;
02570 uint16 yOrg;
02571 uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;
02572 uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
02573 uint8 imageDepth;
02574 uint8 desc;
02575
02576 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(lengthID);
02577 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(cMapType);
02578 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(imageType);
02579 <font class="keywordflow">if</font>(imageType!=2 && imageType!=3 && imageType!=10 && imageType!=11) <font class="keywordflow">return</font>;
02580 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(tgaOrigin);
02581 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(length);
02582 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a391">depth</a>);
02583 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(xOrg);
02584 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(yOrg);
02585 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>);
02586 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>);
02587 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(imageDepth);
02588 <font class="keywordflow">if</font>(imageDepth!=8 && imageDepth!=24 && imageDepth!=32) <font class="keywordflow">return</font>;
02589 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(desc);
02590
02591 <font class="comment">// Ok, we have width and height.</font>
02592 retWidth= <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;
02593 retHeight= <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
02594 }
02595
02596 <font class="comment">// reset stream.</font>
02597 <font class="keywordflow">if</font>(!f.<a class="code" href="classNLMISC_1_1IStream.html#a31">seek</a> (0, <a class="code" href="classNLMISC_1_1IStream.html#s3s0">NLMISC::IStream::begin</a>))
02598 {
02599 <font class="keywordflow">throw</font> ESeekFailed();
02600 }
02601 }
02602
02603
<a name="l02604"></a><a class="code" href="classNLMISC_1_1CBitmap.html#d1">02604</a> <font class="keywordtype">void</font> CBitmap::loadSize(<font class="keyword">const</font> std::string &path, uint32 &retWidth, uint32 &retHeight)
02605 {
02606 retWidth= 0;
02607 retHeight= 0;
02608
02609 CIFile f(path);
02610 <font class="keywordflow">if</font>(f.open(path))
02611 <a class="code" href="classNLMISC_1_1CBitmap.html#d0">loadSize</a>(f, retWidth, retHeight);
02612 }
02613
02614
<a name="l02615"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a25">02615</a> <font class="keywordtype">void</font> CBitmap::flipH()
02616 {
02617 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> != <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>)
02618 <font class="keywordflow">return</font>;
02619
02620 sint32 nWidth = <a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>(0);
02621 sint32 nHeight = <a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>(0);
02622 sint32 i, j;
02623 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pBitmap = (<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>*)&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][0];
02624 <font class="keywordtype">bool</font> needRebuild = <font class="keyword">false</font>;
02625 CRGBA temp;
02626
02627 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>>1)
02628 needRebuild = <font class="keyword">true</font>;
02629 <a class="code" href="classNLMISC_1_1CBitmap.html#a12">releaseMipMaps</a>();
02630
02631 <font class="keywordflow">for</font>( i = 0; i < nHeight; ++i )
02632 <font class="keywordflow">for</font>( j = 0; j < nWidth/2; ++j )
02633 {
02634 temp = pBitmap[i*nWidth+j];
02635 pBitmap[i*nWidth+j] = pBitmap[i*nWidth+nWidth-j-1];
02636 pBitmap[i*nWidth+nWidth-j-1] = temp;
02637 }
02638
02639 <font class="comment">// Rebuilding mipmaps</font>
02640 <font class="keywordflow">if</font>(needRebuild)
02641 {
02642 <a class="code" href="classNLMISC_1_1CBitmap.html#a11">buildMipMaps</a>();
02643 }
02644 }
02645
02646
<a name="l02647"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a26">02647</a> <font class="keywordtype">void</font> CBitmap::flipV()
02648 {
02649 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> != <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>)
02650 <font class="keywordflow">return</font>;
02651
02652 sint32 nWidth = <a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>(0);
02653 sint32 nHeight = <a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>(0);
02654 sint32 i, j;
02655 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pBitmap = (<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>*)&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][0];
02656 <font class="keywordtype">bool</font> needRebuild = <font class="keyword">false</font>;
02657 CRGBA temp;
02658
02659 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>>1)
02660 needRebuild = <font class="keyword">true</font>;
02661 <a class="code" href="classNLMISC_1_1CBitmap.html#a12">releaseMipMaps</a>();
02662
02663 <font class="keywordflow">for</font>( j = 0; j < nHeight/2; ++j )
02664 <font class="keywordflow">for</font>( i = 0; i < nWidth; ++i )
02665 {
02666 temp = pBitmap[j*nWidth+i];
02667 pBitmap[j*nWidth+i] = pBitmap[(nHeight-j-1)*nWidth+i];
02668 pBitmap[(nHeight-j-1)*nWidth+i] = temp;
02669 }
02670
02671 <font class="comment">// Rebuilding mipmaps</font>
02672 <font class="keywordflow">if</font>(needRebuild)
02673 {
02674 <a class="code" href="classNLMISC_1_1CBitmap.html#a11">buildMipMaps</a>();
02675 }
02676 }
02677
02678
<a name="l02679"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a27">02679</a> <font class="keywordtype">void</font> CBitmap::rot90CW()
02680 {
02681 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> != <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>)
02682 <font class="keywordflow">return</font>;
02683 sint32 nWidth = <a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>(0);
02684 sint32 nHeight = <a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>(0);
02685 sint32 i, j;
02686 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pSrcRgba = (<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>*)&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][0];
02687 <font class="keywordtype">bool</font> needRebuild = <font class="keyword">false</font>;
02688
02689 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>>1)
02690 needRebuild = <font class="keyword">true</font>;
02691 <a class="code" href="classNLMISC_1_1CBitmap.html#a12">releaseMipMaps</a>();
02692
02693 std::vector<uint8> pDestui;
02694 pDestui.resize(nWidth*nHeight*4);
02695 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pDestRgba = (<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>*)&pDestui[0];
02696
02697 <font class="keywordflow">for</font>( j = 0; j < nHeight; ++j )
02698 <font class="keywordflow">for</font>( i = 0; i < nWidth; ++i )
02699 pDestRgba[j+i*nHeight] = pSrcRgba[i+(nHeight-1-j)*nWidth];
02700
02701 uint32 nTemp = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
02702 <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
02703 <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> = nTemp;
02704
02705 <a class="code" href="namespaceNLMISC.html#a222">NLMISC::contReset</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0]); <font class="comment">// free memory</font>
02706 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0] = pDestui;
02707 <font class="comment">// Rebuilding mipmaps</font>
02708 <font class="keywordflow">if</font>(needRebuild)
02709 {
02710 <a class="code" href="classNLMISC_1_1CBitmap.html#a11">buildMipMaps</a>();
02711 }
02712 }
02713
<a name="l02714"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a28">02714</a> <font class="keywordtype">void</font> CBitmap::rot90CCW()
02715 {
02716 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CBitmap.html#m0">PixelFormat</a> != <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>)
02717 <font class="keywordflow">return</font>;
02718 sint32 nWidth = <a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>(0);
02719 sint32 nHeight = <a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>(0);
02720 sint32 i, j;
02721 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pSrcRgba = (<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>*)&<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][0];
02722 <font class="keywordtype">bool</font> needRebuild = <font class="keyword">false</font>;
02723
02724 <font class="keywordflow">if</font>(<a class="code" href="classNLMISC_1_1CBitmap.html#n1">_MipMapCount</a>>1)
02725 needRebuild = <font class="keyword">true</font>;
02726 <a class="code" href="classNLMISC_1_1CBitmap.html#a12">releaseMipMaps</a>();
02727
02728 std::vector<uint8> pDestui;
02729 pDestui.resize(nWidth*nHeight*4);
02730 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *pDestRgba = (<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>*)&pDestui[0];
02731
02732 <font class="keywordflow">for</font>( j = 0; j < nHeight; ++j )
02733 <font class="keywordflow">for</font>( i = 0; i < nWidth; ++i )
02734 pDestRgba[j+i*nHeight] = pSrcRgba[nWidth-1-i+j*nWidth];
02735
02736 uint32 nTemp = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a>;
02737 <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>;
02738 <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a> = nTemp;
02739
02740 <a class="code" href="namespaceNLMISC.html#a222">NLMISC::contReset</a>(<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0]); <font class="comment">// free memory</font>
02741 <a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0] = pDestui;
02742 <font class="comment">// Rebuilding mipmaps</font>
02743 <font class="keywordflow">if</font>(needRebuild)
02744 {
02745 <a class="code" href="classNLMISC_1_1CBitmap.html#a11">buildMipMaps</a>();
02746 }
02747 }
02748
02749 <font class="comment">//===========================================================================</font>
02750
<a name="l02751"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a29">02751</a> <font class="keywordtype">void</font> CBitmap::blend(<font class="keyword">const</font> CBitmap &Bm0, <font class="keyword">const</font> CBitmap &Bm1, uint16 factor)
02752 {
02753 <a class="code" href="debug_8h.html#a6">nlassert</a>(factor <= 256);
02754
02755 <a class="code" href="debug_8h.html#a6">nlassert</a>(Bm0._Width != 0 && Bm0._Height != 0
02756 && Bm1._Width != 0 && Bm1._Height != 0);
02757
02758 <a class="code" href="debug_8h.html#a6">nlassert</a>(Bm0._Width == Bm1._Width); <font class="comment">// the bitmap should have the same size</font>
02759 <a class="code" href="debug_8h.html#a6">nlassert</a>(Bm0._Height == Bm1._Height);
02760
02761 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CBitmap.html#a0">CBitmap</a> *nBm0, *nBm1; <font class="comment">// pointer to the bitmap that is used for blending, or to a copy is a conversion wa required</font>
02762
02763 <a class="code" href="classNLMISC_1_1CBitmap.html#a0">CBitmap</a> cp0, cp1; <font class="comment">// these bitmap are copies of Bm1 and Bm0 if a conversion was needed</font>
02764
02765 <font class="keywordflow">if</font> (Bm0.PixelFormat != <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>)
02766 {
02767 cp0 = Bm0;
02768 cp0.convertToRGBA();
02769 nBm0 = &cp0;
02770 }
02771 <font class="keywordflow">else</font>
02772 {
02773 nBm0 = &Bm0;
02774 }
02775
02776
02777 <font class="keywordflow">if</font> (Bm1.PixelFormat != <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>)
02778 {
02779 cp1 = Bm1;
02780 cp1.convertToRGBA();
02781 nBm1 = &cp1;
02782 }
02783 <font class="keywordflow">else</font>
02784 {
02785 nBm1 = &Bm1;
02786 }
02787
02788 this-><a class="code" href="classNLMISC_1_1CBitmap.html#a15">resize</a>(Bm0._Width, Bm0._Height, <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>);
02789
02790 <font class="keyword">const</font> uint numPix = <a class="code" href="classNLMISC_1_1CBitmap.html#n3">_Width</a> * <a class="code" href="classNLMISC_1_1CBitmap.html#n4">_Height</a>; <font class="comment">// 4 component per pixels</font>
02791
02792
02793 <font class="keyword">const</font> uint8 *src0 = &(nBm0->_Data[0][0]);
02794 <font class="keyword">const</font> uint8 *src1 = &(nBm1->_Data[0][0]);
02795 uint8 *dest = &(this-><a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][0]);
02796 uint8 *endPix = dest + (numPix << 2);
02797
02798
02799 uint blendFact = (uint) factor;
02800 uint invblendFact = 256 - blendFact;
02801
02802 <font class="keywordflow">do</font>
02803 {
02805 *dest = (uint8) (((blendFact * *src1) + (invblendFact * *src0)) >> 8);
02806 *(dest + 1) = (uint8) (((blendFact * *(src1 + 1)) + (invblendFact * *(src0 + 1))) >> 8);
02807 *(dest + 2) = (uint8) (((blendFact * *(src1 + 2)) + (invblendFact * *(src0 + 2))) >> 8);
02808 *(dest + 3) = (uint8) (((blendFact * *(src1 + 3)) + (invblendFact * *(src0 + 3))) >> 8);
02809
02810 src0 = src0 + 4;
02811 src1 = src1 + 4;
02812 dest = dest + 4;
02813 }
02814 <font class="keywordflow">while</font> (dest != endPix);
02815 }
02816
02817
02818
02819 <font class="comment">//-----------------------------------------------</font>
02820 CRGBA CBitmap::getRGBAPixel(sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, uint32 numMipMap <font class="comment">/*=0*/</font>)<font class="keyword"> const</font>
02821 <font class="keyword"></font>{
02822 uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>(numMipMap);
02823 uint h = <a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>(numMipMap);
02824 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> == 0 || (uint) <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> >= <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> || (uint) <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> >= h) <font class="keywordflow">return</font> CRGBA::Black; <font class="comment">// include negative cases</font>
02825 <font class="keyword">const</font> uint8 *pix = &<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>(numMipMap)[(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> * <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>) << 2];
02826 <font class="keywordflow">return</font> CRGBA(pix[0], pix[1], pix[2], pix[3]);
02827 }
02828
02829 <font class="comment">//-----------------------------------------------</font>
<a name="l02830"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z276_3">02830</a> CRGBA CBitmap::getDXTCColorFromBlock(<font class="keyword">const</font> uint8 *block, sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>)
02831 {
02832 uint16 col0;
02833 uint16 col1;
02834 memcpy(&col0, block, <font class="keyword">sizeof</font>(uint16));
02835 memcpy(&col1, block + 2, <font class="keyword">sizeof</font>(uint16));
02836 uint colIndex = (block[4 + (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> & 3)] >> ((<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> & 3) << 1)) & 3;
02837 CRGBA result, c0, c1;
02838 <font class="keywordflow">if</font> (col0 > col1)
02839 {
02840 <font class="keywordflow">switch</font>(colIndex)
02841 {
02842 <font class="keywordflow">case</font> 0:
02843 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(col0, result);
02844 <font class="keywordflow">break</font>;
02845 <font class="keywordflow">case</font> 1:
02846 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(col1, result);
02847 <font class="keywordflow">break</font>;
02848 <font class="keywordflow">case</font> 2:
02849 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(col0, c0);
02850 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(col1, c1);
02851 result.blendFromui(c0, c1, 85);
02852 <font class="keywordflow">break</font>;
02853 <font class="keywordflow">case</font> 3:
02854 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(col0, c0);
02855 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(col1, c1);
02856 result.blendFromui(c0, c1, 171);
02857 <font class="keywordflow">break</font>;
02858 }
02859 result.A = 255;
02860 }
02861 <font class="keywordflow">else</font>
02862 {
02863 <font class="keywordflow">switch</font>(colIndex)
02864 {
02865 <font class="keywordflow">case</font> 0:
02866 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(col0, result);
02867 result.A = 255;
02868 <font class="keywordflow">break</font>;
02869 <font class="keywordflow">case</font> 1:
02870 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(col1, result);
02871 result.A = 255;
02872 <font class="keywordflow">break</font>;
02873 <font class="keywordflow">case</font> 2:
02874 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(col0, c0);
02875 <a class="code" href="classNLMISC_1_1CBitmap.html#f0">uncompress</a>(col1, c1);
02876 result.blendFromui(c0, c1, 128);
02877 result.A = 255;
02878 <font class="keywordflow">break</font>;
02879 <font class="keywordflow">case</font> 3:
02880 result.set(0, 0, 0, 0);
02881 <font class="keywordflow">break</font>;
02882 }
02883 }
02884 <font class="keywordflow">return</font> result;
02885 }
02886
02887 <font class="comment">//-----------------------------------------------</font>
<a name="l02888"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z276_0">02888</a> CRGBA CBitmap::getDXTC1Texel(sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, uint32 numMipMap)<font class="keyword"> const</font>
02889 <font class="keyword"></font>{
02890 uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>(numMipMap);
02891 uint h = <a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>(numMipMap);
02892 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> == 0 || h == 0 || (uint) <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> >= <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> || (uint) <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> >= h) <font class="keywordflow">return</font> CRGBA::Black; <font class="comment">// include negative cases </font>
02893 uint numRowBlocks = std::max((<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + 3) >> 2, 1u);
02894 <font class="keyword">const</font> uint8 *pix = &<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>(numMipMap)[0];
02895 <font class="keyword">const</font> uint8 *block = pix + ((<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> >> 2) * (numRowBlocks << 3) + ((x >> 2) << 3));
02896 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z276_3">getDXTCColorFromBlock</a>(block, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
02897 }
02898
02899
02900 <font class="comment">//-----------------------------------------------</font>
<a name="l02901"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z276_1">02901</a> CRGBA CBitmap::getDXTC3Texel(sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, uint32 numMipMap)<font class="keyword"> const</font>
02902 <font class="keyword"></font>{
02903 uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>(numMipMap);
02904 uint h = <a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>(numMipMap);
02905 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> == 0 || h == 0 || (uint) <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> >= <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> || (uint) <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> >= h) <font class="keywordflow">return</font> CRGBA::Black; <font class="comment">// include negative cases </font>
02906 uint numRowBlocks = std::max((<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + 3) >> 2, 1u);
02907 <font class="keyword">const</font> uint8 *pix = &<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>(numMipMap)[0];
02908 <font class="keyword">const</font> uint8 *block = pix + ((<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> >> 2) * (numRowBlocks << 4) + ((x >> 2) << 4));
02909 CRGBA result = <a class="code" href="classNLMISC_1_1CBitmap.html#z276_3">getDXTCColorFromBlock</a>(block + 8, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
02910 <font class="comment">// get alpha part</font>
02911 uint8 alphaByte = block[((<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> & 3) << 1) + ((<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> & 2) >> 1)];
02912 result.A = (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> & 1) ? (alphaByte & 0xf0) : (alphaByte << 4);
02913 <font class="keywordflow">return</font> result;
02914 }
02915
02916 <font class="comment">//-----------------------------------------------</font>
<a name="l02917"></a><a class="code" href="classNLMISC_1_1CBitmap.html#z276_2">02917</a> CRGBA CBitmap::getDXTC5Texel(sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, uint32 numMipMap)<font class="keyword"> const</font>
02918 <font class="keyword"></font>{
02919 uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = <a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>(numMipMap);
02920 uint h = <a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>(numMipMap);
02921 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> == 0 || h == 0 || (uint) <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> >= <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> || (uint) <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> >= h) <font class="keywordflow">return</font> CRGBA::Black; <font class="comment">// include negative cases </font>
02922 uint numRowBlocks = std::max((<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + 3) >> 2, 1u);
02923 <font class="keyword">const</font> uint8 *pix = &<a class="code" href="classNLMISC_1_1CBitmap.html#z277_0">getPixels</a>(numMipMap)[0];
02924 <font class="keyword">const</font> uint8 *block = pix + ((<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> >> 2) * (numRowBlocks << 4) + ((x >> 2) << 4));
02925 CRGBA result = <a class="code" href="classNLMISC_1_1CBitmap.html#z276_3">getDXTCColorFromBlock</a>(block + 8, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
02926 <font class="comment">// get alpha part</font>
02927 uint8 alpha0 = block[0];
02928 uint8 alpha1 = block[1];
02929
02930 uint alphaIndex;
02931 uint tripletIndex = (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> & 3) + ((<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> & 3) << 2);
02932 <font class="keywordflow">if</font> (tripletIndex < 8)
02933 {
02934 alphaIndex = (((uint32 &) block[2]) >> (tripletIndex * 3)) & 7;
02935 }
02936 <font class="keywordflow">else</font>
02937 {
02938 alphaIndex = (((uint32 &) block[5]) >> ((tripletIndex - 8) * 3)) & 7; <font class="comment">// we can read a dword there because there are color datas following he alpha datas</font>
02939 }
02940
02941 <font class="keywordflow">if</font> (alpha0 > alpha1)
02942 {
02943 <font class="keywordflow">switch</font> (alphaIndex)
02944 {
02945 <font class="keywordflow">case</font> 0: result.A = alpha0; <font class="keywordflow">break</font>;
02946 <font class="keywordflow">case</font> 1: result.A = alpha1; <font class="keywordflow">break</font>;
02947 <font class="keywordflow">case</font> 2: result.A = (uint8) ((6 * (uint) alpha0 + (uint) alpha1) / 7); <font class="keywordflow">break</font>;
02948 <font class="keywordflow">case</font> 3: result.A = (uint8) ((5 * (uint) alpha0 + 2 * (uint) alpha1) / 7); <font class="keywordflow">break</font>;
02949 <font class="keywordflow">case</font> 4: result.A = (uint8) ((4 * (uint) alpha0 + 3 * (uint) alpha1) / 7); <font class="keywordflow">break</font>;
02950 <font class="keywordflow">case</font> 5: result.A = (uint8) ((3 * (uint) alpha0 + 4 * (uint) alpha1) / 7); <font class="keywordflow">break</font>;
02951 <font class="keywordflow">case</font> 6: result.A = (uint8) ((2 * (uint) alpha0 + 5 * (uint) alpha1) / 7); <font class="keywordflow">break</font>;
02952 <font class="keywordflow">case</font> 7: result.A = (uint8) (((uint) alpha0 + (uint) 6 * alpha1) / 7); <font class="keywordflow">break</font>;
02953 }
02954 }
02955 <font class="keywordflow">else</font>
02956 {
02957 <font class="keywordflow">switch</font> (alphaIndex)
02958 {
02959 <font class="keywordflow">case</font> 0: result.A = alpha0; <font class="keywordflow">break</font>;
02960 <font class="keywordflow">case</font> 1: result.A = alpha1; <font class="keywordflow">break</font>;
02961 <font class="keywordflow">case</font> 2: result.A = (uint8) ((4 * (uint) alpha0 + (uint) alpha1) / 5); <font class="keywordflow">break</font>;
02962 <font class="keywordflow">case</font> 3: result.A = (uint8) ((3 * (uint) alpha0 + 2 * (uint) alpha1) / 5); <font class="keywordflow">break</font>;
02963 <font class="keywordflow">case</font> 4: result.A = (uint8) ((2 * (uint) alpha0 + 3 * (uint) alpha1) / 5); <font class="keywordflow">break</font>;
02964 <font class="keywordflow">case</font> 5: result.A = (uint8) (((uint) alpha0 + 4 * (uint) alpha1) / 5); <font class="keywordflow">break</font>;
02965 <font class="keywordflow">case</font> 6: result.A = 0; <font class="keywordflow">break</font>;
02966 <font class="keywordflow">case</font> 7: result.A = 255; <font class="keywordflow">break</font>;
02967 }
02968 }
02969 <font class="keywordflow">return</font> result;
02970 }
02971
02972
02973 <font class="comment">//-----------------------------------------------</font>
<a name="l02974"></a><a class="code" href="classNLMISC_1_1CBitmap.html#a24">02974</a> CRGBA CBitmap::getPixelColor(sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, uint32 numMipMap <font class="comment">/*=0*/</font>)<font class="keyword"> const</font>
02975 <font class="keyword"></font>{
02976
02977 <font class="keywordflow">switch</font> (PixelFormat)
02978 {
02979 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s0">RGBA</a>:
02980 <font class="keywordflow">return</font> getRGBAPixel(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, numMipMap);
02981 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s4">DXTC1</a>:
02982 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s5">DXTC1Alpha</a>:
02983 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z276_0">getDXTC1Texel</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, numMipMap);
02984 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s6">DXTC3</a>:
02985 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z276_1">getDXTC3Texel</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, numMipMap);
02986 <font class="keywordflow">case</font> <a class="code" href="classNLMISC_1_1CBitmap.html#s11s7">DXTC5</a>:
02987 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CBitmap.html#z276_2">getDXTC5Texel</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, numMipMap);
02988 <font class="keywordflow">default</font>:
02989 <a class="code" href="debug_8h.html#a12">nlstop</a>;
02990 <font class="keywordflow">break</font>;
02991 }
02992 <font class="keywordflow">return</font> CRGBA::Black;
02993 }
02994
02995
02996 } <font class="comment">// NLMISC</font>
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|