FiberBundleHDF5  FiberHDF5 Documentation, Revision 2026
High-Performance Fiber Bundle Data Model for Scientific Visualization
Loading...
Searching...
No Matches
F5U.h File Reference
#include "F5types.h"
#include "F5WinDLLApi.h"

Go to the source code of this file.

Functions

F5_API int F5UwriteTGA (const char *img_name, int x, int y, F5_rgb_t *buf)
F5_API F5_rgb_tF5UreadTGA (const char *img_name, int *x, int *y)

Function Documentation

◆ F5UreadTGA()

F5_API F5_rgb_t * F5UreadTGA ( const char * img_name,
int * x,
int * y )

Definition at line 45 of file F5Utga.c.

46{
47char tga_name[1024];
48FILE *tga;
49
50 strcpy(tga_name, img_name);
51 strcat(tga_name, ".tga");
52
53 tga = fopen(tga_name, "rb");
54 if (!tga)
55 {
56 perror(img_name);
57 return 0;
58 }
59
60 getc(tga);
61 getc(tga);
62 getc(tga);
63 getc(tga); getc(tga); /* maporg */
64 getc(tga); getc(tga); /* maplen */
65 getc(tga);
66 getc(tga); getc(tga); /* xorigin */
67 getc(tga); getc(tga); /* yorigin */
68 *x=getc(tga)+ (getc(tga)); /* x */
69 *y=getc(tga)+ (getc(tga)); /* x */
70 if (getc(tga)!=24)
71 return 0;
72 getc(tga);
73
74
75 {char*buf = (char*)malloc(*x**y*3);
76 fread(buf,*x**y*3,1,tga);
77 fclose(tga);
78 return (F5_rgb_t*)buf;
79 }
80}

◆ F5UwriteTGA()

F5_API int F5UwriteTGA ( const char * img_name,
int x,
int y,
F5_rgb_t * buf )

Definition at line 11 of file F5Utga.c.

12{
13char tga_name[1024];
14FILE *tga;
15
16 strcpy(tga_name, img_name);
17 strcat(tga_name, ".tga");
18
19 tga = fopen(tga_name, "wb");
20 if (!tga)
21 {
22 perror(img_name);
23 return -1;
24 }
25
26 putc(0,tga);
27 putc(0,tga);
28 putc(2,tga);
29 putc(0,tga); putc( 0,tga); /*maporg*/
30 putc(0,tga); putc( 0,tga); /*maplen*/
31 putc(0,tga);
32 putc(0,tga); putc( 0,tga); /* xorigin*/
33 putc(0,tga); putc( 0,tga); /* yorigin*/
34 putc(x,tga); putc( x>>8,tga); /* x*/
35 putc(y,tga); putc( y>>8,tga); /* y*/
36 putc(24,tga);putc( 0,tga);
37
38 fwrite(buf,x*y*3,1,tga);
39
40 fclose(tga);
41
42 return 0;
43}