home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 January / Chip_1997-01_cd.bin / ms95 / disk21 / dir03 / f012020.re_ / f012020.re
Text File  |  1996-04-02  |  18KB  |  555 lines

  1. /*----------------------------------------------------------------------+
  2. |                                    |
  3. |  Copyright (c) 1985-93;  Bentley Systems, Inc., All rights reserved.    |
  4. |                                    |
  5. | "MicroStation", "MDL", and "MicroCSL" are trademarks of Bentley    |
  6. |  Systems, Inc.                            |
  7. |                                    |
  8. |  Limited permission is hereby granted to reproduce and modify this    |
  9. |  copyrighted material provided that the resulting code is used only     |
  10. |  in conjunction with Bentley Systems products under the terms of the    |
  11. |  license agreement provided therein, and that this notice is retained    |
  12. |  in its entirety in any such reproduction or modification.        |
  13. |                                    |
  14. +----------------------------------------------------------------------*/
  15. /*----------------------------------------------------------------------+
  16. |                                    |
  17. |   $Workfile:   msimage.fdf  $
  18. |   $Revision:   6.3  $
  19. |          $Date:   23 Jun 1995 08:50:50  $
  20. |                                    |
  21. +----------------------------------------------------------------------*/
  22. #if !defined (__msimageFDF__)
  23. #define __msimageFDF__
  24.  
  25. /*----------------------------------------------------------------------+
  26. |                                    |
  27. |   Header File Dependencies                        |
  28. |                                    |
  29. +----------------------------------------------------------------------*/
  30.  
  31. #if !defined (__dloadlibH__)
  32. #include "dloadlib.h"
  33. #endif
  34.  
  35. #if !defined (__mdlH__)
  36. #include "mdl.h"
  37. #endif
  38.  
  39. #if !defined (__globalH__)
  40. #include "global.h"
  41. #endif
  42.  
  43. #if ! defined (__mselemsH__)
  44. #include "mselems.h"
  45. #endif
  46.  
  47. #if ! defined (__imageH__)
  48. #include "image.h"
  49. #endif
  50.  
  51. #if   defined (__BSI__)
  52. #include    <miimage.fdf>
  53. #endif
  54.  
  55. /*======================================================================+
  56. |                                    |
  57. |   Function Definitions                        |
  58. |                                    |
  59. +======================================================================*/
  60.  
  61.  
  62. void mdlDither_drawRow
  63. (
  64. MSWindow *windowP,
  65. long      x0,
  66. long      x1,
  67. long      y,
  68. byte     *red,
  69. byte     *grn,
  70. byte     *blu
  71. );
  72.  
  73.  
  74. int mdlImage_RGBToMapWithGamma
  75. (
  76. byte        **imageMapPP,        /* <= image map */
  77. byte        *rgbBuffer,            /* => image buffer (RGB) */
  78. Point2d        *size,            /* => image size */
  79. byte        *redMap,            /* => red palette entries */
  80. byte        *grnMap,            /* => green palette entries */
  81. byte        *bluMap,            /* => blue palette entries */
  82. int        paletteSize,        /* => number of palette entries */
  83. double        gamma,            /* => gamma correction value */
  84. MdlFunctionP stopFunc            /* => stop function (or NULL) */
  85. );
  86.  
  87. int mdlImage_RGBToMap
  88. (
  89. byte        **imageMap,            /* <= image map */
  90. byte        *rgbBuffer,            /* => image buffer (RGB) */
  91. Point2d        *size,            /* => image size */
  92. byte        *redMap,            /* <= red palette entries */
  93. byte        *grnMap,            /* <= green palette entries */
  94. byte        *bluMap,            /* <= blue palette entries */
  95. int        paletteSize,        /* => number of palette entries */
  96. MdlFunctionP stopFunc            /* => stop function (or NULL) */
  97. );
  98.  
  99. int mdlImage_RGBToScreenMap
  100. (
  101. byte        **mapPP,
  102. byte        *rgbBufferP,
  103. Point2d        *sizeP,
  104. int        screen,
  105. MdlFunctionP    stopFunc            /* => stop function (or NULL) */
  106. );
  107.  
  108. Public int mdlImage_captureScreen
  109. (
  110. byte        **image,            /* <= returned image */
  111. BSIRect     *rectangleP,        /* => rectangle to Capture */
  112. int        screenNum,            /* => physical screen number */
  113. int        imageFormat            /* => returned image format */
  114. );
  115.     
  116. Public int mdlImage_captureScreenMap
  117. (
  118. byte        **imageMap,            /* <= image map */
  119. BSIRect     *rectangleP,        /* => rectangle to Capture */
  120. int        screenNum            /* => physical screen number */
  121. );    
  122.  
  123.  
  124.  
  125. void mdlImage_ditherCleanup
  126. (
  127. void
  128. );
  129.  
  130. int  mdlImage_ditherInitialize
  131. (
  132. int    nColors,        /* => number of palette entries */
  133. byte    *redMapP,        /* => red palette entries */
  134. byte    *grnMapP,        /* => green palette entries */
  135. byte    *bluMapP,        /* => blue palette entries */
  136. int    width            /* => width of scanlines */
  137. );
  138.  
  139. int mdlImage_ditherRow
  140. (
  141. byte    *outputLine,        /* <= color map indices for each pixel */
  142. byte    *redP,            /* => red values for each pixel */
  143. byte    *grnP,            /* => green values for each pixel */
  144. byte    *bluP,            /* => blue values for each pixel */
  145. int    width            /* => number of pixels in scanline */
  146. );
  147.  
  148.  
  149.  
  150.  
  151.  
  152. int mdlImage_getOptimizedPalette
  153. (
  154. byte        *redMap,        /* <= red values for optimized palette */
  155. byte        *grnMap,        /* <= green values for optimized palette */
  156. byte        *bluMap,        /* <= blue values for optimized palette */
  157. int        *paletteSize,    /* <= number of palette entries used */
  158. int        maxColors,        /* => maximum colors in optimized palette */
  159. byte        *imageBuffer,    /* => RGB Values for each image pixel */
  160. Point2d        *size,        /* => size of imageBuffer */
  161. MdlFunctionP stopFunc        /* => function to stop (or NULL) */
  162. );
  163.  
  164.  
  165. int mdlImage_getScreenPalette
  166. (
  167. byte    *redMap,            /* <= red palette entries */
  168. byte    *grnMap,            /* <= green palette entries */
  169. byte    *bluMap,            /* <= blue palette entries */
  170. int    *paletteSize,            /* <= number of palette entries */
  171. int    screenNum            /* => screen number */
  172. );
  173.  
  174. int mdlImage_mapToRGB
  175. (
  176. byte        **rgbBufferPP,        /* <= image buffer (RGB) */
  177. byte        *map,            /* => image map */
  178. Point2d        *size,            /* => image size */
  179. byte        *redMap,            /* => red palette entries */
  180. byte        *grnMap,            /* => green palette entries */
  181. byte        *bluMap,            /* => blue palette entries */
  182. MdlFunctionP stopFunc            /* => stop function (or NULL) */
  183. );
  184.  
  185. int mdlImage_mapToRGBBuffer
  186. (
  187. byte        *rgbBufferP,        /* <= image buffer (RGB) */
  188. byte        *mapP,            /* => image map */
  189. Point2d        *size,            /* => image size */
  190. byte        *redMap,            /* => red palette entries */
  191. byte        *grnMap,            /* => green palette entries */
  192. byte        *bluMap,            /* => blue palette entries */
  193. MdlFunctionP stopFunc            /* => stop function (or NULL) */
  194. );
  195.  
  196.  
  197.  
  198.  
  199.  
  200. int mdlImage_resize
  201. (
  202. byte        **outputImage,        /* <= resized output image (RGB) */
  203. Point2d        *outputSize,        /* => output size */
  204. byte        *inputImage,        /* => input image (RGB) */
  205. Point2d        *inputSize,            /* => input size */
  206. MdlFunctionP stopFunc            /* => stop function (or NULL) */
  207.  
  208. );
  209.  
  210. int mdlImage_saveView
  211. (
  212. char        *fileName,        /* => name of file */
  213. Point2d        *size,        /* => image size */
  214. int        renderMode,        /* => 5=Constant, 6=Smooth, 7=Phong */
  215. int        format,        /* => 1=RGB, 2=Targa, 3=Tiff, 4=Pict */
  216. boolean        stereo,        /* => True for stereo image */
  217. boolean        antiAlias,        /* => True to anti-alias */
  218. int        view        /* => view number */
  219. );
  220.  
  221. int mdlImage_saveViewToRGB
  222. (
  223. byte        **imageBuffer,    /* <= structure of r,g,b colors */
  224. Point2d        *size,        /* => image size */
  225. int        renderMode,        /* => 5=Constant, 6=Smooth, 7=Phong */
  226. boolean        stereo,        /* => True for stereo image */
  227. boolean        antiAlias,        /* => True to anti-alias */
  228. int        view        /* => view number */
  229. );
  230.  
  231. int mdlImage_renderViewToRGB
  232. (
  233. byte        **imageBuffer,      /* <= existing structure to get r,g,b colors */
  234. Point2d        *size,        /* => image size */
  235. int        renderMode,        /* => 5=Constant, 6=Smooth, 7=Phong */
  236. boolean        stereo,        /* => True for stereo image */
  237. boolean        antiAlias,        /* => True to anti-alias */
  238. int        view        /* => view number */
  239. );
  240.  
  241. /*----------------------------------------------------------------------+
  242. |                                    |
  243. |    File read functions                        |
  244. |                                    |
  245. +----------------------------------------------------------------------*/
  246. int mdlImage_readFileInfo
  247. (
  248. Point2d        *imageSize,            /* <= image size */
  249. int        *colorMode,            /* <= color mode  (see image.h) */
  250. int        *orientation,        /* <= orientation (see image.h) */
  251. char        *fileName,            /* => file name */
  252. int        fileType            /* => file type */
  253. );
  254.  
  255. int mdlImage_readFileToRGB
  256. (
  257. byte        **imageBuffer,        /* <= map indices for each pixel */
  258. Point2d        *imageSize,            /* <= image size */
  259. char        *name,            /* => image file name */
  260. int        fileType,            /* => type of file (see image.h) */
  261. Point2d        *requestedSize,        /* => size of output image (or NULL) */
  262. MdlFunctionP stopFunc            /* => stop function (or NULL) */
  263. );
  264.  
  265. int mdlImage_readFileToMap
  266. (
  267. byte        **imageMap,        /* <= image map */
  268. Point2d        *imageSize,        /* <= image size */
  269. byte        *redMap,        /* <= red palette entries */
  270. byte        *grnMap,        /* <= green palette entries */
  271. byte        *bluMap,        /* <= palette entries */
  272. int        *paletteSize,    /* <= palette size */
  273. char        *fileName,        /* => input file name */
  274. int        fileType,        /* => input file type */
  275. MdlFunctionP stopFunc            /* => stop function (or NULL) */
  276. );
  277.  
  278. /*----------------------------------------------------------------------+
  279. |                                    |
  280. |    File creation functions                        |
  281. |                                    |
  282. +----------------------------------------------------------------------*/
  283. int mdlImage_extCreateFileFromMap
  284. (
  285. char        *name,        /* => name of file */
  286. int        type,        /* => type of file (see image.h) */
  287. int        colorMode,        /* => color mode (see image.h) */
  288. Point2d        *size,        /* => size of image */
  289. byte        *imageMap,        /* => color map index for each pixel */
  290. byte        *redPalette,    /* => red palette values */
  291. byte        *grnPalette,    /* => green palette values */
  292. byte        *bluPalette,    /* => blue palette values */
  293. int        paletteSize,    /* => number of palette entries */
  294. int        compression,    /* => quality of image after compression (1-90) */
  295. MdlFunctionP stopFunc            /* => stop function (or NULL) */
  296. );
  297.  
  298. int mdlImage_createFileFromMap
  299. (
  300. char        *name,        /* => name of file */
  301. int        type,        /* => type of file (see image.h) */
  302. int        colorMode,        /* => color mode (see image.h) */
  303. Point2d        *size,        /* => size of image */
  304. byte        *imageMap,        /* => color map index for each pixel */
  305. byte        *redPalette,    /* => red palette values */
  306. byte        *grnPalette,    /* => green palette values */
  307. byte        *bluPalette,    /* => blue palette values */
  308. int        paletteSize,    /* => number of palette entries */
  309. MdlFunctionP stopFunc            /* => stop function (or NULL) */
  310. );
  311.  
  312. int mdlImage_extCreateFileFromRGB
  313. (
  314. char        *name,            /* => name of file    */
  315. int        type,            /* => type of file (see image.h) */
  316. int        colorMode,        /* => color mode (see image.h) */
  317. Point2d        *size,            /* => size of image */
  318. byte        *imageBuffer,        /* => RGB values for each pixel */
  319. int        compression,        /* => degree of compression */
  320. MdlFunctionP stopFunc            /* => stop function (or NULL) */
  321. );
  322.  
  323. int mdlImage_createFileFromRGB
  324. (
  325. char        *name,            /* => name of file    */
  326. int        type,            /* => type of file (see image.h) */
  327. int        colorMode,        /* => color mode (see image.h) */
  328. Point2d        *size,            /* => size of image */
  329. byte        *imageBuffer,        /* => RGB values for each pixel */
  330. MdlFunctionP stopFunc            /* => stop function (or NULL) */
  331. );
  332.  
  333. /*----------------------------------------------------------------------+
  334. |                                    |
  335. |    Movie Functions                             |
  336. |                                    |
  337. +----------------------------------------------------------------------*/
  338. int mdlImage_saveMovie
  339. (
  340. char        *fileName,            /* => file name */
  341. int        fileType,            /* => file type */
  342. int        colorMode,            /* => color mode */
  343. MSMovie        *movieP,            /* => movie to save */
  344. MdlFunctionP stopFunc,             /* => stop function (or NULL) */
  345. MdlFunctionP frameFunc            /* => frame function */
  346. );
  347.  
  348. int mdlImage_extendedSaveMovie
  349. (
  350. char        *fileName,            /* => file name */
  351. int        fileType,            /* => file type */
  352. int        colorMode,            /* => color mode */
  353. MSMovie        *movieP,            /* => movie to save */
  354. int        quality,            /* => quality of compressed image (1-90) */
  355. MdlFunctionP stopFunc,             /* => stop function (or NULL) */
  356. MdlFunctionP frameFunc            /* => frame function */
  357. );
  358.  
  359. int mdlImage_readMovie
  360. (
  361. MSMovie        *movieP,            /* <= movie */
  362. char        *fileName,            /* => file name */
  363. int        fileType,            /* => file type */
  364. byte        *redMap,            /* => red map */
  365. byte        *grnMap,            /* => green map */
  366. byte        *bluMap,            /* => blue map */
  367. int        mapSize,            /* => map size */
  368. double        gammaCorrection,        /* => gamma correction (1.0 == NONE) */
  369. boolean        firstFrameOnly,        /* => TRUE for only one frame */
  370. MdlFunctionP stopFunc,            /* => stop function (or NULL) */
  371. MdlFunctionP frameFunc            /* => frame function */
  372. );
  373.  
  374. int mdlImage_insertMovie
  375. (
  376. MSMovie        *movieP,        /* <=> movie */
  377. MSMovieFrame    *insertFrameP,        /* => frame in movieP to insert at */
  378. MSMovie        *insertMovieP,        /* => movie to insert */
  379. int        transitionType,        /* => type of transition */
  380. int        transitionFrames,   /* => transition frames */
  381. int        stillTransition,    /* => still transition */
  382. MdlFunctionP     stopFunc            /* => stop function (or NULL) */
  383. );
  384.  
  385. int mdlImage_insertMovieFrame
  386. (
  387. MSMovie        *movieP,        /* <=> movie */
  388. MSMovieFrame    *insertFrameP,        /* => frame in movieP to insert at */
  389. byte        *rgbFrameP,        /* => rgb buffer for new frame */
  390. MdlFunctionP     stopFunc            /* => stop function (or NULL) */
  391. );
  392.  
  393. int mdlImage_deleteMovieFrame
  394. (
  395. MSMovie        *movieP,        /* <=> movie */
  396. MSMovieFrame    **framePP        /* => frame to delete */
  397. );
  398.  
  399. void mdlImage_freeMovie
  400. (
  401. MSMovie        *movieP            /* <=> movie to free */
  402. );
  403.  
  404. /*----------------------------------------------------------------------+
  405. |                                    |
  406. |    Miscellaneous functions                        |
  407. |                                    |
  408. +----------------------------------------------------------------------*/
  409. int mdlImage_getExtension
  410. (
  411. char    *extension,        /* <= default extension (3 characters) */
  412. int    type            /* => image type (see image.h) */
  413. );
  414.  
  415. int mdlImage_getOSFileType     /* <= SUCCESS or error. */
  416. (
  417. ULong        *osFileType,    /* <= O.S. file type. */
  418. int        imageType    /* => image type (see image.h) */
  419. );
  420.  
  421. int    mdlImage_getExportSupport
  422. (
  423. int    *defaultMode,            /* <= default color mode */
  424. int    *rgbSupport,            /* <= support for 24 bit RGB */
  425. int    *palette256Support,        /* <= support for 256 color palette */
  426. int    *palette16Support,        /* <= support for 16 color palette */
  427. int    *greyScaleSupport,        /* <= support for grey scale */
  428. int    *monochromeSupport,        /* <= support for monochrome */
  429. int    imageType            /* => image type (see image.h) */
  430. );
  431.  
  432. int  mdlImage_getExportFormat
  433. (
  434. char    *formatName,        /* <= image format name */
  435. int    *importType,        /* <= IMAGEFILE_ type for returned format */
  436. int    index            /* => index of export array to return */
  437. );
  438.  
  439. int  mdlImage_getImportFormat
  440. (
  441. char    *formatName,        /* <= image format name */
  442. int    *importType,        /* <= IMAGEFILE_ type for returned format */
  443. int    index            /* => index of import array to return */
  444. );
  445.  
  446. int mdlImage_createRasterFromRGB
  447. (
  448. MSElementDescr  **edP,            /* <= raster element */
  449. byte        *imageBuffer,        /* => RGB image buffer */
  450. Point2d        *imageSize,        /* => image size (in pixels) */
  451. Dpoint3d    *origin,        /* => origin in current coordinates */
  452. double        scale,            /* => scale factor (current/pixels) */
  453. int        level,            /* => level */
  454. int        useCurrentPalette,    /* => use current color table */
  455. int        transparentBackground,    /* => transparent background */
  456. MdlFunctionP    stopFunc            /* => stop function (or NULL) */
  457. );
  458.  
  459. void mdlImage_getBalancedPalette
  460. (
  461. byte    *redMap,            /* <= red map */
  462. byte    *grnMap,            /* <= green map */
  463. byte    *bluMap,            /* <= blue map */
  464. int    *numColors            /* <= number of colors */
  465. );
  466.  
  467. int mdlImage_typeFromExtension
  468. (
  469. char    *fileName        /* => image file name */
  470. );
  471.  
  472. int    mdlImage_getImageBgColor
  473. (
  474. byte        *pixel,        /* <= 4 bytes to store backround color */
  475. char        *name,
  476. int        fileType
  477. );
  478.  
  479. /*----------------------------------------------------------------------+
  480. |                                    |
  481. |  FLI functions                            |
  482. |                                    |
  483. +----------------------------------------------------------------------*/
  484. int mdlImage_createFli
  485. (
  486. void        **fliFilePP,     /* <=> creates the fliFilePP for all access  */
  487. Point2d        *size,         /* =>  size of the frame in pixels           */
  488. int        speed,         /* =>  desired playback speed in jiffies     */
  489. char        *fileName,         /* =>  qualified pathname of file to create  */
  490. boolean        flcFormat         /* =>  TRUE to create FLC file */
  491. );
  492.  
  493.  
  494. int mdlImage_appendFliFromMap
  495. (
  496. void        *fliP,            /* => fli file */
  497. byte        *mapP,            /* => image */
  498. byte        *redMap,            /* => red map */
  499. byte        *grnMap,            /* => green map */
  500. byte        *bluMap,            /* => blue map */
  501. int        paletteSize,        /* => palette size */
  502. MdlFunctionP stopFunc            /* => stop function (or NULL) */
  503. );
  504.  
  505. int mdlImage_appendFliFromRGB
  506. (
  507. void        *fliP,            /* => fli file (returned by create) */
  508. byte        *redMap,          /* => red map              */
  509. byte        *grnMap,          /* => grn map              */
  510. byte        *bluMap,          /* => blu map              */
  511. int        mapSize,          /* => map size              */
  512. byte        *imageBuffer,     /* => RGB buffer              */
  513. MdlFunctionP stopFunc         /* => stop function (or NULL) */
  514. );
  515.  
  516. void mdlImage_completeFli
  517. (
  518. void        *fliP      /* => close the fli file and compute delta for last frame */
  519. );
  520.  
  521. void mdlImage_applyGamma
  522. (
  523. byte        *rgbOutP,            /* <= output buffer */
  524. byte        *rgbInP,            /* => input buffer */
  525. Point2d        *sizeP,            /* => buffer size */
  526. double        gamma            /* => gamma value (1.0 == NONE) */
  527. );
  528.  
  529. void mdlImage_applyGammaToPalette
  530. (
  531. byte        *redMap,            /* <=> red palette values */
  532. byte        *greenMap,            /* <=> green palette values */
  533. byte        *blueMap,            /* <=> blue palette values */
  534. int        paletteSize,        /* => number of palette entries */
  535. double        gamma            /* => gamma value */
  536. );
  537.  
  538. void mdlImage_negate
  539. (
  540. byte        *rgbOutP,            /* <= output buffer */
  541. byte        *rgbInP,            /* => input buffer */
  542. Point2d        *sizeP            /* => buffer size */
  543. );
  544.  
  545. void mdlImage_negatePalette
  546. (
  547. byte        *redMap,            /* <=> red palette values */
  548. byte        *greenMap,            /* <=> green palette values */
  549. byte        *blueMap,            /* <=> blue palette values */
  550. int        paletteSize            /* => number of palette entries */
  551. );
  552.  
  553.  
  554. #endif
  555.