Merge pull request '第三方库+无人机代码' (#14) from hexuesong into develop
commit
b80ddd1486
@ -0,0 +1,104 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 DAMIÀ FUENTES ESCOTÉ
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
@ -0,0 +1,89 @@
|
||||
# DJITelloPy
|
||||
## [中文文档 (Chinese version of this readme)](README_CN.md)
|
||||
|
||||
DJI Tello drone python interface using the official [Tello SDK](https://dl-cdn.ryzerobotics.com/downloads/tello/20180910/Tello%20SDK%20Documentation%20EN_1.3.pdf) and [Tello EDU SDK](https://dl-cdn.ryzerobotics.com/downloads/Tello/Tello%20SDK%202.0%20User%20Guide.pdf). This library has the following features:
|
||||
|
||||
- implementation of all tello commands
|
||||
- easily retrieve a video stream
|
||||
- receive and parse state packets
|
||||
- control a swarm of drones
|
||||
- support for python >= 3.6
|
||||
|
||||
Feel free to contribute!
|
||||
|
||||
## Install using pip
|
||||
```
|
||||
pip install djitellopy
|
||||
```
|
||||
|
||||
For Linux distributions with both python2 and python3 (e.g. Debian, Ubuntu, ...) you need to run
|
||||
```
|
||||
pip3 install djitellopy
|
||||
```
|
||||
|
||||
## Install in developer mode
|
||||
Using the commands below you can install the repository in an _editable_ way. This allows you to modify the library and use the modified version as if you had installed it regularly.
|
||||
|
||||
```
|
||||
git clone https://github.com/damiafuentes/DJITelloPy.git
|
||||
cd DJITelloPy
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
## Usage
|
||||
### API Reference
|
||||
See [djitellopy.readthedocs.io](https://djitellopy.readthedocs.io/en/latest/) for a full reference of all classes and methods available.
|
||||
|
||||
### Simple example
|
||||
```python
|
||||
from djitellopy import Tello
|
||||
|
||||
tello = Tello()
|
||||
|
||||
tello.connect()
|
||||
tello.takeoff()
|
||||
|
||||
tello.move_left(100)
|
||||
tello.rotate_counter_clockwise(90)
|
||||
tello.move_forward(100)
|
||||
|
||||
tello.land()
|
||||
```
|
||||
|
||||
### More examples
|
||||
In the [examples](examples/) directory there are some code examples.
|
||||
Comments in the examples are mostly in both english and chinese.
|
||||
|
||||
- [taking a picture](examples/take-picture.py)
|
||||
- [recording a video](examples/record-video.py)
|
||||
- [flying a swarm (multiple Tellos at once)](examples/simple-swarm.py)
|
||||
- [simple controlling using your keyboard](examples/manual-control-opencv.py)
|
||||
- [mission pad detection](examples/mission-pads.py)
|
||||
- [fully featured manual control using pygame](examples/manual-control-pygame.py)
|
||||
|
||||
### Notes
|
||||
- If you are using the `streamon` command and the response is `Unknown command` means you have to update the Tello firmware. That can be done through the Tello app.
|
||||
- Mission pad detection and navigation is only supported by the Tello EDU.
|
||||
- Bright environment is necessary for successful use of mission pads.
|
||||
- Connecting to an existing wifi network is only supported by the Tello EDU.
|
||||
- When connected to an existing wifi network video streaming is not available (TODO: needs confirmation with the new SDK3 `port` commands)
|
||||
|
||||
## DJITelloPy in the media and in the wild
|
||||
- \>1.5 Million views Youtube: [Drone Programming With Python Course](https://youtu.be/LmEcyQnfpDA?t=1282)
|
||||
- German magazine "Make": ["KI steuert Follow-Me-Drohne" (paywall)](https://www.heise.de/select/make/2021/6/2116016361503211330), [authors notes](https://www.jentsch.io/ki-artikel-im-aktuellen-make-magazin-6-21/), [github repo](https://github.com/msoftware/tello-tracking)
|
||||
- Webinar on learn.droneblocks.io: ["DJITelloPy Drone Coding"](https://learn.droneblocks.io/p/djitellopy), [github repo](https://learn.droneblocks.io/p/djitellopy)
|
||||
- Universities & Schools using DJITelloPy in projects or in class:
|
||||
- [Ball State University in Muncie, Indiana](https://www.bsu.edu/)
|
||||
- [Technical University Kaiserslautern](https://www.uni-kl.de/)
|
||||
- [Sha Tin College, Hong Kong](https://shatincollege.edu.hk/)
|
||||
- [add yours...](https://github.com/damiafuentes/DJITelloPy/edit/master/README.md)
|
||||
|
||||
## Authors
|
||||
|
||||
* **Damià Fuentes Escoté**
|
||||
* **Jakob Löw**
|
||||
* [and more](https://github.com/damiafuentes/DJITelloPy/graphs/contributors)
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.txt) file for details
|
@ -0,0 +1,2 @@
|
||||
from .tello import Tello, TelloException, BackgroundFrameRead
|
||||
from .swarm import TelloSwarm
|
@ -0,0 +1,65 @@
|
||||
"""
|
||||
This file is based on a StackOverflow post by @301_Moved_Permanently.
|
||||
See https://stackoverflow.com/a/50622643
|
||||
|
||||
The code was adapted to be able to wrap all methods of a class by simply
|
||||
adding the decorator to the class itself.
|
||||
"""
|
||||
|
||||
import inspect
|
||||
import typing
|
||||
from contextlib import suppress
|
||||
from functools import wraps
|
||||
|
||||
|
||||
def _is_unparameterized_special_typing(type_hint):
|
||||
# Check for typing.Any, typing.Union, typing.ClassVar (without parameters)
|
||||
if hasattr(typing, "_SpecialForm"):
|
||||
return isinstance(type_hint, typing._SpecialForm)
|
||||
elif hasattr(type_hint, "__origin__"):
|
||||
return type_hint.__origin__ is None
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def enforce_types(target):
|
||||
"""Class decorator adding type checks to all member functions
|
||||
"""
|
||||
def check_types(spec, *args, **kwargs):
|
||||
parameters = dict(zip(spec.args, args))
|
||||
parameters.update(kwargs)
|
||||
for name, value in parameters.items():
|
||||
with suppress(KeyError): # Assume un-annotated parameters can be any type
|
||||
type_hint = spec.annotations[name]
|
||||
if _is_unparameterized_special_typing(type_hint):
|
||||
continue
|
||||
|
||||
if hasattr(type_hint, "__origin__") and type_hint.__origin__ is not None:
|
||||
actual_type = type_hint.__origin__
|
||||
elif hasattr(type_hint, "__args__") and type_hint.__args__ is not None:
|
||||
actual_type = type_hint.__args__
|
||||
else:
|
||||
actual_type = type_hint
|
||||
|
||||
if not isinstance(value, actual_type):
|
||||
raise TypeError("Unexpected type for '{}' (expected {} but found {})"
|
||||
.format(name, type_hint, type(value)))
|
||||
|
||||
def decorate(func):
|
||||
spec = inspect.getfullargspec(func)
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
check_types(spec, *args, **kwargs)
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
if inspect.isclass(target):
|
||||
members = inspect.getmembers(target, predicate=inspect.isfunction)
|
||||
for name, func in members:
|
||||
setattr(target, name, decorate(func))
|
||||
|
||||
return target
|
||||
else:
|
||||
return decorate(target)
|
@ -0,0 +1,159 @@
|
||||
"""Library for controlling multiple DJI Ryze Tello drones.
|
||||
"""
|
||||
|
||||
from threading import Thread, Barrier
|
||||
from queue import Queue
|
||||
from typing import List, Callable
|
||||
|
||||
from .tello import Tello, TelloException
|
||||
from .enforce_types import enforce_types
|
||||
|
||||
|
||||
@enforce_types
|
||||
class TelloSwarm:
|
||||
"""Swarm library for controlling multiple Tellos simultaneously
|
||||
"""
|
||||
|
||||
tellos: List[Tello]
|
||||
barrier: Barrier
|
||||
funcBarier: Barrier
|
||||
funcQueues: List[Queue]
|
||||
threads: List[Thread]
|
||||
|
||||
@staticmethod
|
||||
def fromFile(path: str):
|
||||
"""Create TelloSwarm from file. The file should contain one IP address per line.
|
||||
|
||||
Arguments:
|
||||
path: path to the file
|
||||
"""
|
||||
with open(path, 'r') as fd:
|
||||
ips = fd.readlines()
|
||||
|
||||
return TelloSwarm.fromIps(ips)
|
||||
|
||||
@staticmethod
|
||||
def fromIps(ips: list):
|
||||
"""Create TelloSwarm from a list of IP addresses.
|
||||
|
||||
Arguments:
|
||||
ips: list of IP Addresses
|
||||
"""
|
||||
if not ips:
|
||||
raise TelloException("No ips provided")
|
||||
|
||||
tellos = []
|
||||
for ip in ips:
|
||||
tellos.append(Tello(ip.strip()))
|
||||
|
||||
return TelloSwarm(tellos)
|
||||
|
||||
def __init__(self, tellos: List[Tello]):
|
||||
"""Initialize a TelloSwarm instance
|
||||
|
||||
Arguments:
|
||||
tellos: list of [Tello][tello] instances
|
||||
"""
|
||||
self.tellos = tellos
|
||||
self.barrier = Barrier(len(tellos))
|
||||
self.funcBarrier = Barrier(len(tellos) + 1)
|
||||
self.funcQueues = [Queue() for tello in tellos]
|
||||
|
||||
def worker(i):
|
||||
queue = self.funcQueues[i]
|
||||
tello = self.tellos[i]
|
||||
|
||||
while True:
|
||||
func = queue.get()
|
||||
self.funcBarrier.wait()
|
||||
func(i, tello)
|
||||
self.funcBarrier.wait()
|
||||
|
||||
self.threads = []
|
||||
for i, _ in enumerate(tellos):
|
||||
thread = Thread(target=worker, daemon=True, args=(i,))
|
||||
thread.start()
|
||||
self.threads.append(thread)
|
||||
|
||||
def sequential(self, func: Callable[[int, Tello], None]):
|
||||
"""Call `func` for each tello sequentially. The function retrieves
|
||||
two arguments: The index `i` of the current drone and `tello` the
|
||||
current [Tello][tello] instance.
|
||||
|
||||
```python
|
||||
swarm.parallel(lambda i, tello: tello.land())
|
||||
```
|
||||
"""
|
||||
|
||||
for i, tello in enumerate(self.tellos):
|
||||
func(i, tello)
|
||||
|
||||
def parallel(self, func: Callable[[int, Tello], None]):
|
||||
"""Call `func` for each tello in parallel. The function retrieves
|
||||
two arguments: The index `i` of the current drone and `tello` the
|
||||
current [Tello][tello] instance.
|
||||
|
||||
You can use `swarm.sync()` for syncing between threads.
|
||||
|
||||
```python
|
||||
swarm.parallel(lambda i, tello: tello.move_up(50 + i * 10))
|
||||
```
|
||||
"""
|
||||
|
||||
for queue in self.funcQueues:
|
||||
queue.put(func)
|
||||
|
||||
self.funcBarrier.wait()
|
||||
self.funcBarrier.wait()
|
||||
|
||||
def sync(self, timeout: float = None):
|
||||
"""Sync parallel tello threads. The code continues when all threads
|
||||
have called `swarm.sync`.
|
||||
|
||||
```python
|
||||
def doStuff(i, tello):
|
||||
tello.move_up(50 + i * 10)
|
||||
swarm.sync()
|
||||
|
||||
if i == 2:
|
||||
tello.flip_back()
|
||||
# make all other drones wait for one to complete its flip
|
||||
swarm.sync()
|
||||
|
||||
swarm.parallel(doStuff)
|
||||
```
|
||||
"""
|
||||
return self.barrier.wait(timeout)
|
||||
|
||||
def __getattr__(self, attr):
|
||||
"""Call a standard tello function in parallel on all tellos.
|
||||
|
||||
```python
|
||||
swarm.command()
|
||||
swarm.takeoff()
|
||||
swarm.move_up(50)
|
||||
```
|
||||
"""
|
||||
def callAll(*args, **kwargs):
|
||||
self.parallel(lambda i, tello: getattr(tello, attr)(*args, **kwargs))
|
||||
|
||||
return callAll
|
||||
|
||||
def __iter__(self):
|
||||
"""Iterate over all drones in the swarm.
|
||||
|
||||
```python
|
||||
for tello in swarm:
|
||||
print(tello.get_battery())
|
||||
```
|
||||
"""
|
||||
return iter(self.tellos)
|
||||
|
||||
def __len__(self):
|
||||
"""Return the amount of tellos in the swarm
|
||||
|
||||
```python
|
||||
print("Tello count: {}".format(len(swarm)))
|
||||
```
|
||||
"""
|
||||
return len(self.tellos)
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,5 @@
|
||||
mkdocs>=1.1.2
|
||||
mkdocs-material>=5.2.2
|
||||
mkdocstrings>=0.11.2
|
||||
numpy==1.15.4
|
||||
opencv-python==3.4.3.18
|
@ -0,0 +1,28 @@
|
||||
# DJITelloPy
|
||||
|
||||
This documentation is the API reference of the DJITelloPy Library.
|
||||
|
||||
For more information on the project please see the [readme on github](https://github.com/damiafuentes/DJITelloPy/blob/master/README.md).
|
||||
|
||||
## API
|
||||
|
||||
Currently the library contains the following classes:
|
||||
|
||||
- [Tello][tello] for controlling a single tello drone.
|
||||
- [Swarm][swarm] for controlling multiple Tello EDUs in parallel.
|
||||
|
||||
## Example Code
|
||||
|
||||
Please see the [example directory](https://github.com/damiafuentes/DJITelloPy/tree/master/examples) on github.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install djitellopy
|
||||
```
|
||||
|
||||
For Linux distributions with both python2 and python3 (e.g. Debian, Ubuntu, ...) you need to run
|
||||
|
||||
```bash
|
||||
pip3 install djitellopy
|
||||
```
|
@ -0,0 +1,5 @@
|
||||
# Swarm
|
||||
|
||||
::: djitellopy.TelloSwarm
|
||||
:docstring:
|
||||
:members:
|
@ -0,0 +1,5 @@
|
||||
# Tello
|
||||
|
||||
::: djitellopy.Tello
|
||||
:docstring:
|
||||
:members:
|
@ -0,0 +1,34 @@
|
||||
from djitellopy import Tello
|
||||
|
||||
# create and connect
|
||||
# 创建Tello对象并连接
|
||||
tello = Tello()
|
||||
tello.connect()
|
||||
|
||||
# configure drone
|
||||
# 设置无人机
|
||||
tello.enable_mission_pads()
|
||||
tello.set_mission_pad_detection_direction(1) # forward detection only 只识别前方
|
||||
|
||||
tello.takeoff()
|
||||
|
||||
pad = tello.get_mission_pad_id()
|
||||
|
||||
# detect and react to pads until we see pad #1
|
||||
# 发现并识别挑战卡直到看见1号挑战卡
|
||||
while pad != 1:
|
||||
if pad == 3:
|
||||
tello.move_back(30)
|
||||
tello.rotate_clockwise(90)
|
||||
|
||||
if pad == 4:
|
||||
tello.move_up(30)
|
||||
tello.flip_forward()
|
||||
|
||||
pad = tello.get_mission_pad_id()
|
||||
|
||||
# graceful termination
|
||||
# 安全结束程序
|
||||
tello.disable_mission_pads()
|
||||
tello.land()
|
||||
tello.end()
|
@ -0,0 +1,16 @@
|
||||
#Simply import of "panoramaModule.py" and you can use each function by calling it with name of the drone inside arguments.
|
||||
from djitellopy import Tello
|
||||
import cv2
|
||||
import time
|
||||
import panoramaModule
|
||||
|
||||
|
||||
tello = Tello()
|
||||
tello.connect()
|
||||
|
||||
print(tello.get_battery())
|
||||
|
||||
tello.takeoff()
|
||||
tello.move_up(500)
|
||||
panoramaModule.panorama_half_clockwise(tello)
|
||||
tello.land()
|
@ -0,0 +1,88 @@
|
||||
#Module with individual panorama types defined. You can just import it and use hovever you like
|
||||
#
|
||||
#It will save photos from Tello inside folder that's in. You can change this by changing path inside every function.
|
||||
from djitellopy import Tello
|
||||
import cv2
|
||||
import time
|
||||
|
||||
global img
|
||||
|
||||
|
||||
def panorama_full_clockwise(tello_name):
|
||||
tello = tello_name
|
||||
tello.streamoff()
|
||||
tello.streamon()
|
||||
|
||||
for i in range(4):
|
||||
img = tello.get_frame_read().frame
|
||||
cv2.imwrite(f'Panorama-full-clockwise_{time.time()}.jpg', img)
|
||||
time.sleep(1)
|
||||
tello.rotate_clockwise(80)
|
||||
|
||||
img = tello.get_frame_read().frame
|
||||
cv2.imwrite(f'Panorama-full-clockwise_{time.time()}.jpg', img)
|
||||
time.sleep(1)
|
||||
tello.rotate_clockwise(40)
|
||||
|
||||
tello.streamoff()
|
||||
|
||||
|
||||
def panorama_half_clockwise(tello_name):
|
||||
tello = tello_name
|
||||
tello.streamoff()
|
||||
tello.streamon()
|
||||
|
||||
tello.rotate_counter_clockwise(90)
|
||||
|
||||
for i in range(3):
|
||||
img = tello.get_frame_read().frame
|
||||
cv2.imwrite(f'Panorama-half-clockwise_{time.time()}.jpg', img)
|
||||
time.sleep(1)
|
||||
tello.rotate_clockwise(60)
|
||||
|
||||
img = tello.get_frame_read().frame
|
||||
cv2.imwrite(f'Panorama-half-clockwise_{time.time()}.jpg', img)
|
||||
time.sleep(1)
|
||||
tello.rotate_counter_clockwise(90)
|
||||
|
||||
tello.streamoff()
|
||||
|
||||
|
||||
def panorama_full_counter_clockwise(tello_name):
|
||||
tello = tello_name
|
||||
tello.streamoff()
|
||||
tello.streamon()
|
||||
|
||||
for i in range(4):
|
||||
img = tello.get_frame_read().frame
|
||||
cv2.imwrite(f'Panorama-full-counter-clockwise_{time.time()}.jpg', img)
|
||||
time.sleep(1)
|
||||
tello.rotate_counter_clockwise(80)
|
||||
|
||||
img = tello.get_frame_read().frame
|
||||
cv2.imwrite(f'/Panorama-full-counter-clockwise_{time.time()}.jpg', img)
|
||||
time.sleep(1)
|
||||
tello.rotate_counter_clockwise(40)
|
||||
|
||||
tello.streamoff()
|
||||
|
||||
|
||||
def panorama_half_counter_clockwise(tello_name):
|
||||
tello = tello_name
|
||||
tello.streamoff()
|
||||
tello.streamon()
|
||||
|
||||
tello.rotate_clockwise(90)
|
||||
|
||||
for i in range(3):
|
||||
img = tello.get_frame_read().frame
|
||||
cv2.imwrite(f'Panorama-half-counter-clockwise_{time.time()}.jpg', img)
|
||||
time.sleep(1)
|
||||
tello.rotate_counter_clockwise(60)
|
||||
|
||||
img = tello.get_frame_read().frame
|
||||
cv2.imwrite(f'Panorama_half_counter_clockwise-{time.time()}.jpg', img)
|
||||
time.sleep(1)
|
||||
tello.rotate_clockwise(90)
|
||||
|
||||
tello.streamoff()
|
@ -0,0 +1,25 @@
|
||||
from djitellopy import TelloSwarm
|
||||
|
||||
swarm = TelloSwarm.fromIps([
|
||||
"192.168.178.42",
|
||||
"192.168.178.43",
|
||||
"192.168.178.44"
|
||||
])
|
||||
|
||||
swarm.connect()
|
||||
swarm.takeoff()
|
||||
|
||||
# run in parallel on all tellos
|
||||
# 同时在所有Tello上执行
|
||||
swarm.move_up(100)
|
||||
|
||||
# run by one tello after the other
|
||||
# 让Tello一个接一个执行
|
||||
swarm.sequential(lambda i, tello: tello.move_forward(i * 20 + 20))
|
||||
|
||||
# making each tello do something unique in parallel
|
||||
# 让每一架Tello单独执行不同的操作
|
||||
swarm.parallel(lambda i, tello: tello.move_left(i * 100 + 20))
|
||||
|
||||
swarm.land()
|
||||
swarm.end()
|
@ -0,0 +1,12 @@
|
||||
from djitellopy import Tello
|
||||
|
||||
tello = Tello()
|
||||
|
||||
tello.connect()
|
||||
tello.takeoff()
|
||||
|
||||
tello.move_left(100)
|
||||
tello.rotate_clockwise(90)
|
||||
tello.move_forward(100)
|
||||
|
||||
tello.land()
|
@ -0,0 +1,13 @@
|
||||
import cv2
|
||||
from djitellopy import Tello
|
||||
|
||||
tello = Tello()
|
||||
tello.connect()
|
||||
|
||||
tello.streamon()
|
||||
frame_read = tello.get_frame_read()
|
||||
|
||||
tello.takeoff()
|
||||
cv2.imwrite("picture.png", frame_read.frame)
|
||||
|
||||
tello.land()
|
@ -0,0 +1,22 @@
|
||||
site_name: DJITelloPy API Reference
|
||||
site_url: "https://djitellopy.readthedocs.io/en/latest/"
|
||||
repo_url: "https://github.com/damiafuentes/DJITelloPy"
|
||||
repo_name: "damiafuentes/DJITelloPy"
|
||||
|
||||
theme:
|
||||
name: "material"
|
||||
|
||||
markdown_extensions:
|
||||
- admonition
|
||||
- codehilite
|
||||
|
||||
plugins:
|
||||
- search
|
||||
- mkdocstrings:
|
||||
default_handler: python
|
||||
handlers:
|
||||
python:
|
||||
rendering:
|
||||
show_source: true
|
||||
watch:
|
||||
- djitellopy/
|
@ -0,0 +1,3 @@
|
||||
numpy==1.20.1
|
||||
av==8.0.3
|
||||
pillow==8.4.0
|
@ -0,0 +1,3 @@
|
||||
# Inside of setup.cfg
|
||||
[metadata]
|
||||
description-file = README.md
|
@ -0,0 +1,38 @@
|
||||
import setuptools
|
||||
|
||||
with open("README.md", "r", encoding="utf-8") as fd:
|
||||
long_description = fd.read()
|
||||
|
||||
# replace relative urls to example files with absolute urls to the main git repo
|
||||
repo_code_url = "https://github.com/damiafuentes/DJITelloPy/tree/master"
|
||||
long_description = long_description.replace("](examples/", "]({}/examples/".format(repo_code_url))
|
||||
|
||||
setuptools.setup(
|
||||
name='djitellopy',
|
||||
packages=['djitellopy'],
|
||||
version='2.4.0',
|
||||
license='MIT',
|
||||
description='Tello drone library including support for video streaming, swarms, state packets and more',
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/markdown',
|
||||
author='Jakob Löw',
|
||||
author_email='djitellopy@m4gnus.de',
|
||||
url='https://github.com/damiafuentes/DJITelloPy',
|
||||
download_url='https://github.com/damiafuentes/DJITelloPy/archive/2.4.0.tar.gz',
|
||||
keywords=['tello', 'dji', 'drone', 'sdk', 'official sdk'],
|
||||
install_requires=[
|
||||
'numpy',
|
||||
'opencv-python',
|
||||
],
|
||||
python_requires='>=3.6',
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Intended Audience :: Developers',
|
||||
'Topic :: Software Development :: Build Tools',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
],
|
||||
)
|
@ -0,0 +1,404 @@
|
||||
# This is the CMakeCache file.
|
||||
# For build in directory: d:/rgsj/colmap-build
|
||||
# It was generated by CMake: D:/rgsj/map/cmake-3.21.0-rc1-windows-x86_64/bin/cmake.exe
|
||||
# You can edit this file to change values found and used by cmake.
|
||||
# If you do not want to change any of the values, simply exit the editor.
|
||||
# If you do want to change a value, simply edit, save, and exit the editor.
|
||||
# The syntax for the file is as follows:
|
||||
# KEY:TYPE=VALUE
|
||||
# KEY is the name of a variable in the cache.
|
||||
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
|
||||
# VALUE is the current value for the KEY.
|
||||
|
||||
########################
|
||||
# EXTERNAL cache entries
|
||||
########################
|
||||
|
||||
//Whether to enable AddressSanitizer flags
|
||||
ASAN_ENABLED:BOOL=OFF
|
||||
|
||||
//Whether to enable static boost library linker flags
|
||||
BOOST_STATIC:BOOL=ON
|
||||
|
||||
//Whether to enable compiler caching, if available
|
||||
CCACHE_ENABLED:BOOL=ON
|
||||
|
||||
//Whether to enable the CGAL library
|
||||
CGAL_ENABLED:BOOL=ON
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_AR:FILEPATH=D:/vss/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/lib.exe
|
||||
|
||||
//Semicolon separated list of supported configuration types, only
|
||||
// supports Debug, Release, MinSizeRel, and RelWithDebInfo, anything
|
||||
// else will be ignored.
|
||||
CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release;MinSizeRel;RelWithDebInfo
|
||||
|
||||
//Flags used by the CXX compiler during all build types.
|
||||
CMAKE_CXX_FLAGS:STRING=/DWIN32 /D_WINDOWS /W3 /GR /EHsc
|
||||
|
||||
//Flags used by the CXX compiler during DEBUG builds.
|
||||
CMAKE_CXX_FLAGS_DEBUG:STRING=/MDd /Zi /Ob0 /Od /RTC1
|
||||
|
||||
//Flags used by the CXX compiler during MINSIZEREL builds.
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /DNDEBUG
|
||||
|
||||
//Flags used by the CXX compiler during RELEASE builds.
|
||||
CMAKE_CXX_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /DNDEBUG
|
||||
|
||||
//Flags used by the CXX compiler during RELWITHDEBINFO builds.
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2 /Ob1 /DNDEBUG
|
||||
|
||||
//Libraries linked by default with all C++ applications.
|
||||
CMAKE_CXX_STANDARD_LIBRARIES:STRING=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
|
||||
|
||||
//Flags used by the C compiler during all build types.
|
||||
CMAKE_C_FLAGS:STRING=/DWIN32 /D_WINDOWS /W3
|
||||
|
||||
//Flags used by the C compiler during DEBUG builds.
|
||||
CMAKE_C_FLAGS_DEBUG:STRING=/MDd /Zi /Ob0 /Od /RTC1
|
||||
|
||||
//Flags used by the C compiler during MINSIZEREL builds.
|
||||
CMAKE_C_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /DNDEBUG
|
||||
|
||||
//Flags used by the C compiler during RELEASE builds.
|
||||
CMAKE_C_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /DNDEBUG
|
||||
|
||||
//Flags used by the C compiler during RELWITHDEBINFO builds.
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2 /Ob1 /DNDEBUG
|
||||
|
||||
//Libraries linked by default with all C applications.
|
||||
CMAKE_C_STANDARD_LIBRARIES:STRING=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
|
||||
|
||||
//Flags used by the linker during all build types.
|
||||
CMAKE_EXE_LINKER_FLAGS:STRING=/machine:x64
|
||||
|
||||
//Flags used by the linker during DEBUG builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL
|
||||
|
||||
//Flags used by the linker during MINSIZEREL builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO
|
||||
|
||||
//Flags used by the linker during RELEASE builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO
|
||||
|
||||
//Flags used by the linker during RELWITHDEBINFO builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL
|
||||
|
||||
//Install path prefix, prepended onto install directories.
|
||||
CMAKE_INSTALL_PREFIX:PATH=C:/Program Files/COLMAP
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_LINKER:FILEPATH=D:/vss/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/link.exe
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// all build types.
|
||||
CMAKE_MODULE_LINKER_FLAGS:STRING=/machine:x64
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// DEBUG builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// MINSIZEREL builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// RELEASE builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// RELWITHDEBINFO builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_MT:FILEPATH=CMAKE_MT-NOTFOUND
|
||||
|
||||
CMAKE_PREFIX_PATH:PATH=D:/rgsj/colmap-build
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_DESCRIPTION:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_HOMEPAGE_URL:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_NAME:STATIC=COLMAP
|
||||
|
||||
//RC compiler
|
||||
CMAKE_RC_COMPILER:FILEPATH=rc
|
||||
|
||||
//Flags for Windows Resource Compiler during all build types.
|
||||
CMAKE_RC_FLAGS:STRING=-DWIN32
|
||||
|
||||
//Flags for Windows Resource Compiler during DEBUG builds.
|
||||
CMAKE_RC_FLAGS_DEBUG:STRING=-D_DEBUG
|
||||
|
||||
//Flags for Windows Resource Compiler during MINSIZEREL builds.
|
||||
CMAKE_RC_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags for Windows Resource Compiler during RELEASE builds.
|
||||
CMAKE_RC_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags for Windows Resource Compiler during RELWITHDEBINFO builds.
|
||||
CMAKE_RC_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during all build types.
|
||||
CMAKE_SHARED_LINKER_FLAGS:STRING=/machine:x64
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during DEBUG builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during MINSIZEREL builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during RELEASE builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during RELWITHDEBINFO builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL
|
||||
|
||||
//If set, runtime paths are not added when installing shared libraries,
|
||||
// but are added when building.
|
||||
CMAKE_SKIP_INSTALL_RPATH:BOOL=OFF
|
||||
|
||||
//If set, runtime paths are not added when using shared libraries.
|
||||
CMAKE_SKIP_RPATH:BOOL=OFF
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during all build types.
|
||||
CMAKE_STATIC_LINKER_FLAGS:STRING=/machine:x64
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during DEBUG builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during MINSIZEREL builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during RELEASE builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during RELWITHDEBINFO builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//If this value is on, makefiles will be generated without the
|
||||
// .SILENT directive, and all commands will be echoed to the console
|
||||
// during the make. This is useful for debugging only. With Visual
|
||||
// Studio IDE projects all commands are done without /nologo.
|
||||
CMAKE_VERBOSE_MAKEFILE:BOOL=OFF
|
||||
|
||||
//Value Computed by CMake
|
||||
COLMAP_BINARY_DIR:STATIC=D:/rgsj/colmap-build
|
||||
|
||||
//Value Computed by CMake
|
||||
COLMAP_IS_TOP_LEVEL:STATIC=ON
|
||||
|
||||
//Value Computed by CMake
|
||||
COLMAP_SOURCE_DIR:STATIC=D:/rgsj/colmap-dev
|
||||
|
||||
//List of CUDA architectures for which to generate code, e.g.,
|
||||
// Auto, All, Maxwell, Pascal, ...
|
||||
CUDA_ARCHS:STRING=Auto
|
||||
|
||||
//Whether to enable CUDA, if available
|
||||
CUDA_ENABLED:BOOL=ON
|
||||
|
||||
//The directory containing a CMake configuration file for Ceres.
|
||||
Ceres_DIR:PATH=Ceres_DIR-NOTFOUND
|
||||
|
||||
EIGEN3_INCLUDE_DIRS:PATH=D:/rgsj/CERES_SOLVER/eigen-3.3.9
|
||||
|
||||
//Whether to enable the graphical UI
|
||||
GUI_ENABLED:BOOL=ON
|
||||
|
||||
//Whether to enable interprocedural optimization
|
||||
IPO_ENABLED:BOOL=ON
|
||||
|
||||
//Whether to enable OpenGL, if available
|
||||
OPENGL_ENABLED:BOOL=ON
|
||||
|
||||
//Whether to enable OpenMP parallelization
|
||||
OPENMP_ENABLED:BOOL=ON
|
||||
|
||||
//CXX compiler flags for OpenMP parallelization
|
||||
OpenMP_CXX_FLAGS:STRING=-openmp
|
||||
|
||||
//CXX compiler libraries for OpenMP parallelization
|
||||
OpenMP_CXX_LIB_NAMES:STRING=
|
||||
|
||||
//C compiler flags for OpenMP parallelization
|
||||
OpenMP_C_FLAGS:STRING=-openmp
|
||||
|
||||
//C compiler libraries for OpenMP parallelization
|
||||
OpenMP_C_LIB_NAMES:STRING=
|
||||
|
||||
//Whether to enable google-perftools linker flags
|
||||
PROFILING_ENABLED:BOOL=OFF
|
||||
|
||||
//Whether to enable SIMD optimizations
|
||||
SIMD_ENABLED:BOOL=ON
|
||||
|
||||
//Whether to build test binaries
|
||||
TESTS_ENABLED:BOOL=OFF
|
||||
|
||||
|
||||
########################
|
||||
# INTERNAL cache entries
|
||||
########################
|
||||
|
||||
//ADVANCED property for variable: CMAKE_AR
|
||||
CMAKE_AR-ADVANCED:INTERNAL=1
|
||||
//This is the directory where this CMakeCache.txt was created
|
||||
CMAKE_CACHEFILE_DIR:INTERNAL=d:/rgsj/colmap-build
|
||||
//Major version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
|
||||
//Minor version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MINOR_VERSION:INTERNAL=21
|
||||
//Patch version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_PATCH_VERSION:INTERNAL=0
|
||||
//Path to CMake executable.
|
||||
CMAKE_COMMAND:INTERNAL=D:/rgsj/map/cmake-3.21.0-rc1-windows-x86_64/bin/cmake.exe
|
||||
//Path to cpack program executable.
|
||||
CMAKE_CPACK_COMMAND:INTERNAL=D:/rgsj/map/cmake-3.21.0-rc1-windows-x86_64/bin/cpack.exe
|
||||
//Path to ctest program executable.
|
||||
CMAKE_CTEST_COMMAND:INTERNAL=D:/rgsj/map/cmake-3.21.0-rc1-windows-x86_64/bin/ctest.exe
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_STANDARD_LIBRARIES
|
||||
CMAKE_CXX_STANDARD_LIBRARIES-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_STANDARD_LIBRARIES
|
||||
CMAKE_C_STANDARD_LIBRARIES-ADVANCED:INTERNAL=1
|
||||
//Executable file format
|
||||
CMAKE_EXECUTABLE_FORMAT:INTERNAL=Unknown
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
|
||||
CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
|
||||
CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
|
||||
CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//Name of external makefile project generator.
|
||||
CMAKE_EXTRA_GENERATOR:INTERNAL=
|
||||
//Name of generator.
|
||||
CMAKE_GENERATOR:INTERNAL=Visual Studio 15 2017
|
||||
//Generator instance identifier.
|
||||
CMAKE_GENERATOR_INSTANCE:INTERNAL=D:/vss
|
||||
//Name of generator platform.
|
||||
CMAKE_GENERATOR_PLATFORM:INTERNAL=x64
|
||||
//Name of generator toolset.
|
||||
CMAKE_GENERATOR_TOOLSET:INTERNAL=
|
||||
//Source directory with the top level CMakeLists.txt file for this
|
||||
// project
|
||||
CMAKE_HOME_DIRECTORY:INTERNAL=D:/rgsj/colmap-dev
|
||||
//ADVANCED property for variable: CMAKE_LINKER
|
||||
CMAKE_LINKER-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
|
||||
CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
|
||||
CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MT
|
||||
CMAKE_MT-ADVANCED:INTERNAL=1
|
||||
//number of local generators
|
||||
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1
|
||||
//Platform information initialized
|
||||
CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
|
||||
//noop for ranlib
|
||||
CMAKE_RANLIB:INTERNAL=:
|
||||
//ADVANCED property for variable: CMAKE_RC_COMPILER
|
||||
CMAKE_RC_COMPILER-ADVANCED:INTERNAL=1
|
||||
CMAKE_RC_COMPILER_WORKS:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_RC_FLAGS
|
||||
CMAKE_RC_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_RC_FLAGS_DEBUG
|
||||
CMAKE_RC_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_RC_FLAGS_MINSIZEREL
|
||||
CMAKE_RC_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_RC_FLAGS_RELEASE
|
||||
CMAKE_RC_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_RC_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_RC_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//Path to CMake installation.
|
||||
CMAKE_ROOT:INTERNAL=D:/rgsj/map/cmake-3.21.0-rc1-windows-x86_64/share/cmake-3.21
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
|
||||
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
|
||||
CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
|
||||
CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SKIP_RPATH
|
||||
CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS
|
||||
CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG
|
||||
CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
|
||||
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
|
||||
//Result of TRY_COMPILE
|
||||
OpenMP_COMPILE_RESULT_CXX_openmp:INTERNAL=TRUE
|
||||
//Result of TRY_COMPILE
|
||||
OpenMP_COMPILE_RESULT_C_openmp:INTERNAL=TRUE
|
||||
//ADVANCED property for variable: OpenMP_CXX_FLAGS
|
||||
OpenMP_CXX_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: OpenMP_CXX_LIB_NAMES
|
||||
OpenMP_CXX_LIB_NAMES-ADVANCED:INTERNAL=1
|
||||
//CXX compiler's OpenMP specification date
|
||||
OpenMP_CXX_SPEC_DATE:INTERNAL=200203
|
||||
//ADVANCED property for variable: OpenMP_C_FLAGS
|
||||
OpenMP_C_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: OpenMP_C_LIB_NAMES
|
||||
OpenMP_C_LIB_NAMES-ADVANCED:INTERNAL=1
|
||||
//C compiler's OpenMP specification date
|
||||
OpenMP_C_SPEC_DATE:INTERNAL=200203
|
||||
//Result of TRY_COMPILE
|
||||
OpenMP_SPECTEST_CXX_:INTERNAL=TRUE
|
||||
//Result of TRY_COMPILE
|
||||
OpenMP_SPECTEST_C_:INTERNAL=TRUE
|
||||
|
@ -0,0 +1,80 @@
|
||||
set(CMAKE_C_COMPILER "D:/vss/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe")
|
||||
set(CMAKE_C_COMPILER_ARG1 "")
|
||||
set(CMAKE_C_COMPILER_ID "MSVC")
|
||||
set(CMAKE_C_COMPILER_VERSION "19.16.27045.0")
|
||||
set(CMAKE_C_COMPILER_VERSION_INTERNAL "")
|
||||
set(CMAKE_C_COMPILER_WRAPPER "")
|
||||
set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "90")
|
||||
set(CMAKE_C_COMPILE_FEATURES "c_std_90;c_std_99;c_std_11;c_function_prototypes;c_variadic_macros")
|
||||
set(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes")
|
||||
set(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_variadic_macros")
|
||||
set(CMAKE_C11_COMPILE_FEATURES "c_std_11")
|
||||
set(CMAKE_C17_COMPILE_FEATURES "")
|
||||
set(CMAKE_C23_COMPILE_FEATURES "")
|
||||
|
||||
set(CMAKE_C_PLATFORM_ID "Windows")
|
||||
set(CMAKE_C_SIMULATE_ID "")
|
||||
set(CMAKE_C_COMPILER_FRONTEND_VARIANT "")
|
||||
set(CMAKE_C_SIMULATE_VERSION "")
|
||||
set(CMAKE_C_COMPILER_ARCHITECTURE_ID x64)
|
||||
|
||||
set(MSVC_C_ARCHITECTURE_ID x64)
|
||||
|
||||
set(CMAKE_AR "D:/vss/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/lib.exe")
|
||||
set(CMAKE_C_COMPILER_AR "")
|
||||
set(CMAKE_RANLIB ":")
|
||||
set(CMAKE_C_COMPILER_RANLIB "")
|
||||
set(CMAKE_LINKER "D:/vss/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/link.exe")
|
||||
set(CMAKE_MT "CMAKE_MT-NOTFOUND")
|
||||
set(CMAKE_COMPILER_IS_GNUCC )
|
||||
set(CMAKE_C_COMPILER_LOADED 1)
|
||||
set(CMAKE_C_COMPILER_WORKS TRUE)
|
||||
set(CMAKE_C_ABI_COMPILED TRUE)
|
||||
set(CMAKE_COMPILER_IS_MINGW )
|
||||
set(CMAKE_COMPILER_IS_CYGWIN )
|
||||
if(CMAKE_COMPILER_IS_CYGWIN)
|
||||
set(CYGWIN 1)
|
||||
set(UNIX 1)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER_ENV_VAR "CC")
|
||||
|
||||
if(CMAKE_COMPILER_IS_MINGW)
|
||||
set(MINGW 1)
|
||||
endif()
|
||||
set(CMAKE_C_COMPILER_ID_RUN 1)
|
||||
set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
|
||||
set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
|
||||
set(CMAKE_C_LINKER_PREFERENCE 10)
|
||||
|
||||
# Save compiler ABI information.
|
||||
set(CMAKE_C_SIZEOF_DATA_PTR "8")
|
||||
set(CMAKE_C_COMPILER_ABI "")
|
||||
set(CMAKE_C_BYTE_ORDER "LITTLE_ENDIAN")
|
||||
set(CMAKE_C_LIBRARY_ARCHITECTURE "")
|
||||
|
||||
if(CMAKE_C_SIZEOF_DATA_PTR)
|
||||
set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ABI)
|
||||
set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_LIBRARY_ARCHITECTURE)
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE "")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "")
|
||||
if(CMAKE_C_CL_SHOWINCLUDES_PREFIX)
|
||||
set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "")
|
||||
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "")
|
||||
set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "")
|
||||
set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
|
@ -0,0 +1,91 @@
|
||||
set(CMAKE_CXX_COMPILER "D:/vss/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe")
|
||||
set(CMAKE_CXX_COMPILER_ARG1 "")
|
||||
set(CMAKE_CXX_COMPILER_ID "MSVC")
|
||||
set(CMAKE_CXX_COMPILER_VERSION "19.16.27045.0")
|
||||
set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "")
|
||||
set(CMAKE_CXX_COMPILER_WRAPPER "")
|
||||
set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "14")
|
||||
set(CMAKE_CXX_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters;cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates;cxx_std_17;cxx_std_20")
|
||||
set(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters")
|
||||
set(CMAKE_CXX11_COMPILE_FEATURES "cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates")
|
||||
set(CMAKE_CXX14_COMPILE_FEATURES "cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates")
|
||||
set(CMAKE_CXX17_COMPILE_FEATURES "cxx_std_17")
|
||||
set(CMAKE_CXX20_COMPILE_FEATURES "cxx_std_20")
|
||||
set(CMAKE_CXX23_COMPILE_FEATURES "")
|
||||
|
||||
set(CMAKE_CXX_PLATFORM_ID "Windows")
|
||||
set(CMAKE_CXX_SIMULATE_ID "")
|
||||
set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "")
|
||||
set(CMAKE_CXX_SIMULATE_VERSION "")
|
||||
set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID x64)
|
||||
|
||||
set(MSVC_CXX_ARCHITECTURE_ID x64)
|
||||
|
||||
set(CMAKE_AR "D:/vss/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/lib.exe")
|
||||
set(CMAKE_CXX_COMPILER_AR "")
|
||||
set(CMAKE_RANLIB ":")
|
||||
set(CMAKE_CXX_COMPILER_RANLIB "")
|
||||
set(CMAKE_LINKER "D:/vss/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/link.exe")
|
||||
set(CMAKE_MT "CMAKE_MT-NOTFOUND")
|
||||
set(CMAKE_COMPILER_IS_GNUCXX )
|
||||
set(CMAKE_CXX_COMPILER_LOADED 1)
|
||||
set(CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
set(CMAKE_CXX_ABI_COMPILED TRUE)
|
||||
set(CMAKE_COMPILER_IS_MINGW )
|
||||
set(CMAKE_COMPILER_IS_CYGWIN )
|
||||
if(CMAKE_COMPILER_IS_CYGWIN)
|
||||
set(CYGWIN 1)
|
||||
set(UNIX 1)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_COMPILER_ENV_VAR "CXX")
|
||||
|
||||
if(CMAKE_COMPILER_IS_MINGW)
|
||||
set(MINGW 1)
|
||||
endif()
|
||||
set(CMAKE_CXX_COMPILER_ID_RUN 1)
|
||||
set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;mpp;CPP;ixx;cppm)
|
||||
set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
|
||||
|
||||
foreach (lang C OBJC OBJCXX)
|
||||
if (CMAKE_${lang}_COMPILER_ID_RUN)
|
||||
foreach(extension IN LISTS CMAKE_${lang}_SOURCE_FILE_EXTENSIONS)
|
||||
list(REMOVE_ITEM CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${extension})
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(CMAKE_CXX_LINKER_PREFERENCE 30)
|
||||
set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1)
|
||||
|
||||
# Save compiler ABI information.
|
||||
set(CMAKE_CXX_SIZEOF_DATA_PTR "8")
|
||||
set(CMAKE_CXX_COMPILER_ABI "")
|
||||
set(CMAKE_CXX_BYTE_ORDER "LITTLE_ENDIAN")
|
||||
set(CMAKE_CXX_LIBRARY_ARCHITECTURE "")
|
||||
|
||||
if(CMAKE_CXX_SIZEOF_DATA_PTR)
|
||||
set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ABI)
|
||||
set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_LIBRARY_ARCHITECTURE)
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE "")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX "")
|
||||
if(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX)
|
||||
set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX}")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "")
|
||||
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
|
||||
set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "")
|
||||
set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
set(CMAKE_RC_COMPILER "rc")
|
||||
set(CMAKE_RC_COMPILER_ARG1 "")
|
||||
set(CMAKE_RC_COMPILER_LOADED 1)
|
||||
set(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc;RC)
|
||||
set(CMAKE_RC_OUTPUT_EXTENSION .res)
|
||||
set(CMAKE_RC_COMPILER_ENV_VAR "RC")
|
@ -0,0 +1,15 @@
|
||||
set(CMAKE_HOST_SYSTEM "Windows-10.0.19044")
|
||||
set(CMAKE_HOST_SYSTEM_NAME "Windows")
|
||||
set(CMAKE_HOST_SYSTEM_VERSION "10.0.19044")
|
||||
set(CMAKE_HOST_SYSTEM_PROCESSOR "AMD64")
|
||||
|
||||
|
||||
|
||||
set(CMAKE_SYSTEM "Windows-10.0.19044")
|
||||
set(CMAKE_SYSTEM_NAME "Windows")
|
||||
set(CMAKE_SYSTEM_VERSION "10.0.19044")
|
||||
set(CMAKE_SYSTEM_PROCESSOR "AMD64")
|
||||
|
||||
set(CMAKE_CROSSCOMPILING "FALSE")
|
||||
|
||||
set(CMAKE_SYSTEM_LOADED 1)
|
@ -0,0 +1,807 @@
|
||||
#ifdef __cplusplus
|
||||
# error "A C++ compiler has been selected for C."
|
||||
#endif
|
||||
|
||||
#if defined(__18CXX)
|
||||
# define ID_VOID_MAIN
|
||||
#endif
|
||||
#if defined(__CLASSIC_C__)
|
||||
/* cv-qualifiers did not exist in K&R C */
|
||||
# define const
|
||||
# define volatile
|
||||
#endif
|
||||
|
||||
#if !defined(__has_include)
|
||||
/* If the compiler does not have __has_include, pretend the answer is
|
||||
always no. */
|
||||
# define __has_include(x) 0
|
||||
#endif
|
||||
|
||||
|
||||
/* Version number components: V=Version, R=Revision, P=Patch
|
||||
Version date components: YYYY=Year, MM=Month, DD=Day */
|
||||
|
||||
#if defined(__INTEL_COMPILER) || defined(__ICC)
|
||||
# define COMPILER_ID "Intel"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# if defined(__GNUC__)
|
||||
# define SIMULATE_ID "GNU"
|
||||
# endif
|
||||
/* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later,
|
||||
except that a few beta releases use the old format with V=2021. */
|
||||
# if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
|
||||
# if defined(__INTEL_COMPILER_UPDATE)
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
|
||||
# else
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
|
||||
# endif
|
||||
# else
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE)
|
||||
/* The third version component from --version is an update index,
|
||||
but no macro is provided for it. */
|
||||
# define COMPILER_VERSION_PATCH DEC(0)
|
||||
# endif
|
||||
# if defined(__INTEL_COMPILER_BUILD_DATE)
|
||||
/* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
|
||||
# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
|
||||
# endif
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
# if defined(__GNUC__)
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
|
||||
# elif defined(__GNUG__)
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
|
||||
# endif
|
||||
# if defined(__GNUC_MINOR__)
|
||||
# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
|
||||
# endif
|
||||
# if defined(__GNUC_PATCHLEVEL__)
|
||||
# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER)
|
||||
# define COMPILER_ID "IntelLLVM"
|
||||
#if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
# define SIMULATE_ID "GNU"
|
||||
#endif
|
||||
/* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and
|
||||
* later. Look for 6 digit vs. 8 digit version number to decide encoding.
|
||||
* VVVV is no smaller than the current year when a version is released.
|
||||
*/
|
||||
#if __INTEL_LLVM_COMPILER < 1000000L
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10)
|
||||
#else
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100)
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
|
||||
#elif defined(__GNUG__)
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
|
||||
#endif
|
||||
#if defined(__GNUC_MINOR__)
|
||||
# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
|
||||
#endif
|
||||
#if defined(__GNUC_PATCHLEVEL__)
|
||||
# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
||||
#endif
|
||||
|
||||
#elif defined(__PATHCC__)
|
||||
# define COMPILER_ID "PathScale"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
|
||||
# if defined(__PATHCC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
|
||||
# define COMPILER_ID "Embarcadero"
|
||||
# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
|
||||
# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
|
||||
# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
|
||||
|
||||
#elif defined(__BORLANDC__)
|
||||
# define COMPILER_ID "Borland"
|
||||
/* __BORLANDC__ = 0xVRR */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
|
||||
# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
|
||||
|
||||
#elif defined(__WATCOMC__) && __WATCOMC__ < 1200
|
||||
# define COMPILER_ID "Watcom"
|
||||
/* __WATCOMC__ = VVRR */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
||||
# if (__WATCOMC__ % 10) > 0
|
||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# define COMPILER_ID "OpenWatcom"
|
||||
/* __WATCOMC__ = VVRP + 1100 */
|
||||
# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
||||
# if (__WATCOMC__ % 10) > 0
|
||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__SUNPRO_C)
|
||||
# define COMPILER_ID "SunPro"
|
||||
# if __SUNPRO_C >= 0x5100
|
||||
/* __SUNPRO_C = 0xVRRP */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
|
||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
|
||||
# else
|
||||
/* __SUNPRO_CC = 0xVRP */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
|
||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
|
||||
# endif
|
||||
|
||||
#elif defined(__HP_cc)
|
||||
# define COMPILER_ID "HP"
|
||||
/* __HP_cc = VVRRPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__HP_cc % 100)
|
||||
|
||||
#elif defined(__DECC)
|
||||
# define COMPILER_ID "Compaq"
|
||||
/* __DECC_VER = VVRRTPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)
|
||||
|
||||
#elif defined(__IBMC__) && defined(__COMPILER_VER__)
|
||||
# define COMPILER_ID "zOS"
|
||||
/* __IBMC__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
|
||||
|
||||
#elif defined(__ibmxl__) && defined(__clang__)
|
||||
# define COMPILER_ID "XLClang"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
|
||||
# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
|
||||
|
||||
|
||||
#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800
|
||||
# define COMPILER_ID "XL"
|
||||
/* __IBMC__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
|
||||
|
||||
#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800
|
||||
# define COMPILER_ID "VisualAge"
|
||||
/* __IBMC__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
|
||||
|
||||
#elif defined(__NVCOMPILER)
|
||||
# define COMPILER_ID "NVHPC"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__)
|
||||
# if defined(__NVCOMPILER_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(__PGI)
|
||||
# define COMPILER_ID "PGI"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
|
||||
# if defined(__PGIC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(_CRAYC)
|
||||
# define COMPILER_ID "Cray"
|
||||
# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
|
||||
# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
|
||||
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
# define COMPILER_ID "TI"
|
||||
/* __TI_COMPILER_VERSION__ = VVVRRRPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
|
||||
# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
|
||||
|
||||
#elif defined(__CLANG_FUJITSU)
|
||||
# define COMPILER_ID "FujitsuClang"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
|
||||
# define COMPILER_VERSION_INTERNAL_STR __clang_version__
|
||||
|
||||
|
||||
#elif defined(__FUJITSU)
|
||||
# define COMPILER_ID "Fujitsu"
|
||||
# if defined(__FCC_version__)
|
||||
# define COMPILER_VERSION __FCC_version__
|
||||
# elif defined(__FCC_major__)
|
||||
# define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
|
||||
# endif
|
||||
# if defined(__fcc_version)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__fcc_version)
|
||||
# elif defined(__FCC_VERSION)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION)
|
||||
# endif
|
||||
|
||||
|
||||
#elif defined(__ghs__)
|
||||
# define COMPILER_ID "GHS"
|
||||
/* __GHS_VERSION_NUMBER = VVVVRP */
|
||||
# ifdef __GHS_VERSION_NUMBER
|
||||
# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__TINYC__)
|
||||
# define COMPILER_ID "TinyCC"
|
||||
|
||||
#elif defined(__BCC__)
|
||||
# define COMPILER_ID "Bruce"
|
||||
|
||||
#elif defined(__SCO_VERSION__)
|
||||
# define COMPILER_ID "SCO"
|
||||
|
||||
#elif defined(__ARMCC_VERSION) && !defined(__clang__)
|
||||
# define COMPILER_ID "ARMCC"
|
||||
#if __ARMCC_VERSION >= 1000000
|
||||
/* __ARMCC_VERSION = VRRPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
||||
#else
|
||||
/* __ARMCC_VERSION = VRPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
||||
#endif
|
||||
|
||||
|
||||
#elif defined(__clang__) && defined(__apple_build_version__)
|
||||
# define COMPILER_ID "AppleClang"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
|
||||
|
||||
#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION)
|
||||
# define COMPILER_ID "ARMClang"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION % 10000)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION)
|
||||
|
||||
#elif defined(__clang__) && __has_include(<hip/hip_version.h>)
|
||||
# define COMPILER_ID "ROCMClang"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# elif defined(__clang__)
|
||||
# define SIMULATE_ID "Clang"
|
||||
# elif defined(__GNUC__)
|
||||
# define SIMULATE_ID "GNU"
|
||||
# endif
|
||||
# if defined(__clang__) && __has_include(<hip/hip_version.h>)
|
||||
# include <hip/hip_version.h>
|
||||
# define COMPILER_VERSION_MAJOR DEC(HIP_VERSION_MAJOR)
|
||||
# define COMPILER_VERSION_MINOR DEC(HIP_VERSION_MINOR)
|
||||
# define COMPILER_VERSION_PATCH DEC(HIP_VERSION_PATCH)
|
||||
# endif
|
||||
|
||||
#elif defined(__clang__)
|
||||
# define COMPILER_ID "Clang"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
# define COMPILER_ID "GNU"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
|
||||
# if defined(__GNUC_MINOR__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
|
||||
# endif
|
||||
# if defined(__GNUC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# define COMPILER_ID "MSVC"
|
||||
/* _MSC_VER = VVRR */
|
||||
# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# if defined(_MSC_FULL_VER)
|
||||
# if _MSC_VER >= 1400
|
||||
/* _MSC_FULL_VER = VVRRPPPPP */
|
||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
|
||||
# else
|
||||
/* _MSC_FULL_VER = VVRRPPPP */
|
||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
|
||||
# endif
|
||||
# endif
|
||||
# if defined(_MSC_BUILD)
|
||||
# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
|
||||
# endif
|
||||
|
||||
#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
|
||||
# define COMPILER_ID "ADSP"
|
||||
#if defined(__VISUALDSPVERSION__)
|
||||
/* __VISUALDSPVERSION__ = 0xVVRRPP00 */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
|
||||
# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
|
||||
#endif
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
|
||||
# define COMPILER_ID "IAR"
|
||||
# if defined(__VER__) && defined(__ICCARM__)
|
||||
# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
|
||||
# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
|
||||
# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__))
|
||||
# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
|
||||
# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
|
||||
# endif
|
||||
|
||||
#elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC)
|
||||
# define COMPILER_ID "SDCC"
|
||||
# if defined(__SDCC_VERSION_MAJOR)
|
||||
# define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR)
|
||||
# define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR)
|
||||
# define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH)
|
||||
# else
|
||||
/* SDCC = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(SDCC/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(SDCC % 10)
|
||||
# endif
|
||||
|
||||
|
||||
/* These compilers are either not known or too old to define an
|
||||
identification macro. Try to identify the platform and guess that
|
||||
it is the native compiler. */
|
||||
#elif defined(__hpux) || defined(__hpua)
|
||||
# define COMPILER_ID "HP"
|
||||
|
||||
#else /* unknown compiler */
|
||||
# define COMPILER_ID ""
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
|
||||
#ifdef SIMULATE_ID
|
||||
char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
|
||||
#endif
|
||||
|
||||
#ifdef __QNXNTO__
|
||||
char const* qnxnto = "INFO" ":" "qnxnto[]";
|
||||
#endif
|
||||
|
||||
#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
|
||||
char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
|
||||
#endif
|
||||
|
||||
#define STRINGIFY_HELPER(X) #X
|
||||
#define STRINGIFY(X) STRINGIFY_HELPER(X)
|
||||
|
||||
/* Identify known platforms by name. */
|
||||
#if defined(__linux) || defined(__linux__) || defined(linux)
|
||||
# define PLATFORM_ID "Linux"
|
||||
|
||||
#elif defined(__MSYS__)
|
||||
# define PLATFORM_ID "MSYS"
|
||||
|
||||
#elif defined(__CYGWIN__)
|
||||
# define PLATFORM_ID "Cygwin"
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# define PLATFORM_ID "MinGW"
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
# define PLATFORM_ID "Darwin"
|
||||
|
||||
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
||||
# define PLATFORM_ID "Windows"
|
||||
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD)
|
||||
# define PLATFORM_ID "FreeBSD"
|
||||
|
||||
#elif defined(__NetBSD__) || defined(__NetBSD)
|
||||
# define PLATFORM_ID "NetBSD"
|
||||
|
||||
#elif defined(__OpenBSD__) || defined(__OPENBSD)
|
||||
# define PLATFORM_ID "OpenBSD"
|
||||
|
||||
#elif defined(__sun) || defined(sun)
|
||||
# define PLATFORM_ID "SunOS"
|
||||
|
||||
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
|
||||
# define PLATFORM_ID "AIX"
|
||||
|
||||
#elif defined(__hpux) || defined(__hpux__)
|
||||
# define PLATFORM_ID "HP-UX"
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
# define PLATFORM_ID "Haiku"
|
||||
|
||||
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
|
||||
# define PLATFORM_ID "BeOS"
|
||||
|
||||
#elif defined(__QNX__) || defined(__QNXNTO__)
|
||||
# define PLATFORM_ID "QNX"
|
||||
|
||||
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
|
||||
# define PLATFORM_ID "Tru64"
|
||||
|
||||
#elif defined(__riscos) || defined(__riscos__)
|
||||
# define PLATFORM_ID "RISCos"
|
||||
|
||||
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
|
||||
# define PLATFORM_ID "SINIX"
|
||||
|
||||
#elif defined(__UNIX_SV__)
|
||||
# define PLATFORM_ID "UNIX_SV"
|
||||
|
||||
#elif defined(__bsdos__)
|
||||
# define PLATFORM_ID "BSDOS"
|
||||
|
||||
#elif defined(_MPRAS) || defined(MPRAS)
|
||||
# define PLATFORM_ID "MP-RAS"
|
||||
|
||||
#elif defined(__osf) || defined(__osf__)
|
||||
# define PLATFORM_ID "OSF1"
|
||||
|
||||
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
|
||||
# define PLATFORM_ID "SCO_SV"
|
||||
|
||||
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
|
||||
# define PLATFORM_ID "ULTRIX"
|
||||
|
||||
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
|
||||
# define PLATFORM_ID "Xenix"
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(__LINUX__)
|
||||
# define PLATFORM_ID "Linux"
|
||||
|
||||
# elif defined(__DOS__)
|
||||
# define PLATFORM_ID "DOS"
|
||||
|
||||
# elif defined(__OS2__)
|
||||
# define PLATFORM_ID "OS2"
|
||||
|
||||
# elif defined(__WINDOWS__)
|
||||
# define PLATFORM_ID "Windows3x"
|
||||
|
||||
# elif defined(__VXWORKS__)
|
||||
# define PLATFORM_ID "VxWorks"
|
||||
|
||||
# else /* unknown platform */
|
||||
# define PLATFORM_ID
|
||||
# endif
|
||||
|
||||
#elif defined(__INTEGRITY)
|
||||
# if defined(INT_178B)
|
||||
# define PLATFORM_ID "Integrity178"
|
||||
|
||||
# else /* regular Integrity */
|
||||
# define PLATFORM_ID "Integrity"
|
||||
# endif
|
||||
|
||||
#else /* unknown platform */
|
||||
# define PLATFORM_ID
|
||||
|
||||
#endif
|
||||
|
||||
/* For windows compilers MSVC and Intel we can determine
|
||||
the architecture of the compiler being used. This is because
|
||||
the compilers do not have flags that can change the architecture,
|
||||
but rather depend on which compiler is being used
|
||||
*/
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
# if defined(_M_IA64)
|
||||
# define ARCHITECTURE_ID "IA64"
|
||||
|
||||
# elif defined(_M_ARM64EC)
|
||||
# define ARCHITECTURE_ID "ARM64EC"
|
||||
|
||||
# elif defined(_M_X64) || defined(_M_AMD64)
|
||||
# define ARCHITECTURE_ID "x64"
|
||||
|
||||
# elif defined(_M_IX86)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# elif defined(_M_ARM64)
|
||||
# define ARCHITECTURE_ID "ARM64"
|
||||
|
||||
# elif defined(_M_ARM)
|
||||
# if _M_ARM == 4
|
||||
# define ARCHITECTURE_ID "ARMV4I"
|
||||
# elif _M_ARM == 5
|
||||
# define ARCHITECTURE_ID "ARMV5I"
|
||||
# else
|
||||
# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
|
||||
# endif
|
||||
|
||||
# elif defined(_M_MIPS)
|
||||
# define ARCHITECTURE_ID "MIPS"
|
||||
|
||||
# elif defined(_M_SH)
|
||||
# define ARCHITECTURE_ID "SHx"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(_M_I86)
|
||||
# define ARCHITECTURE_ID "I86"
|
||||
|
||||
# elif defined(_M_IX86)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
|
||||
# if defined(__ICCARM__)
|
||||
# define ARCHITECTURE_ID "ARM"
|
||||
|
||||
# elif defined(__ICCRX__)
|
||||
# define ARCHITECTURE_ID "RX"
|
||||
|
||||
# elif defined(__ICCRH850__)
|
||||
# define ARCHITECTURE_ID "RH850"
|
||||
|
||||
# elif defined(__ICCRL78__)
|
||||
# define ARCHITECTURE_ID "RL78"
|
||||
|
||||
# elif defined(__ICCRISCV__)
|
||||
# define ARCHITECTURE_ID "RISCV"
|
||||
|
||||
# elif defined(__ICCAVR__)
|
||||
# define ARCHITECTURE_ID "AVR"
|
||||
|
||||
# elif defined(__ICC430__)
|
||||
# define ARCHITECTURE_ID "MSP430"
|
||||
|
||||
# elif defined(__ICCV850__)
|
||||
# define ARCHITECTURE_ID "V850"
|
||||
|
||||
# elif defined(__ICC8051__)
|
||||
# define ARCHITECTURE_ID "8051"
|
||||
|
||||
# elif defined(__ICCSTM8__)
|
||||
# define ARCHITECTURE_ID "STM8"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__ghs__)
|
||||
# if defined(__PPC64__)
|
||||
# define ARCHITECTURE_ID "PPC64"
|
||||
|
||||
# elif defined(__ppc__)
|
||||
# define ARCHITECTURE_ID "PPC"
|
||||
|
||||
# elif defined(__ARM__)
|
||||
# define ARCHITECTURE_ID "ARM"
|
||||
|
||||
# elif defined(__x86_64__)
|
||||
# define ARCHITECTURE_ID "x64"
|
||||
|
||||
# elif defined(__i386__)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
# if defined(__TI_ARM__)
|
||||
# define ARCHITECTURE_ID "ARM"
|
||||
|
||||
# elif defined(__MSP430__)
|
||||
# define ARCHITECTURE_ID "MSP430"
|
||||
|
||||
# elif defined(__TMS320C28XX__)
|
||||
# define ARCHITECTURE_ID "TMS320C28x"
|
||||
|
||||
# elif defined(__TMS320C6X__) || defined(_TMS320C6X)
|
||||
# define ARCHITECTURE_ID "TMS320C6x"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#else
|
||||
# define ARCHITECTURE_ID
|
||||
#endif
|
||||
|
||||
/* Convert integer to decimal digit literals. */
|
||||
#define DEC(n) \
|
||||
('0' + (((n) / 10000000)%10)), \
|
||||
('0' + (((n) / 1000000)%10)), \
|
||||
('0' + (((n) / 100000)%10)), \
|
||||
('0' + (((n) / 10000)%10)), \
|
||||
('0' + (((n) / 1000)%10)), \
|
||||
('0' + (((n) / 100)%10)), \
|
||||
('0' + (((n) / 10)%10)), \
|
||||
('0' + ((n) % 10))
|
||||
|
||||
/* Convert integer to hex digit literals. */
|
||||
#define HEX(n) \
|
||||
('0' + ((n)>>28 & 0xF)), \
|
||||
('0' + ((n)>>24 & 0xF)), \
|
||||
('0' + ((n)>>20 & 0xF)), \
|
||||
('0' + ((n)>>16 & 0xF)), \
|
||||
('0' + ((n)>>12 & 0xF)), \
|
||||
('0' + ((n)>>8 & 0xF)), \
|
||||
('0' + ((n)>>4 & 0xF)), \
|
||||
('0' + ((n) & 0xF))
|
||||
|
||||
/* Construct a string literal encoding the version number. */
|
||||
#ifdef COMPILER_VERSION
|
||||
char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]";
|
||||
|
||||
/* Construct a string literal encoding the version number components. */
|
||||
#elif defined(COMPILER_VERSION_MAJOR)
|
||||
char const info_version[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
|
||||
COMPILER_VERSION_MAJOR,
|
||||
# ifdef COMPILER_VERSION_MINOR
|
||||
'.', COMPILER_VERSION_MINOR,
|
||||
# ifdef COMPILER_VERSION_PATCH
|
||||
'.', COMPILER_VERSION_PATCH,
|
||||
# ifdef COMPILER_VERSION_TWEAK
|
||||
'.', COMPILER_VERSION_TWEAK,
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
']','\0'};
|
||||
#endif
|
||||
|
||||
/* Construct a string literal encoding the internal version number. */
|
||||
#ifdef COMPILER_VERSION_INTERNAL
|
||||
char const info_version_internal[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
|
||||
'i','n','t','e','r','n','a','l','[',
|
||||
COMPILER_VERSION_INTERNAL,']','\0'};
|
||||
#elif defined(COMPILER_VERSION_INTERNAL_STR)
|
||||
char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]";
|
||||
#endif
|
||||
|
||||
/* Construct a string literal encoding the version number components. */
|
||||
#ifdef SIMULATE_VERSION_MAJOR
|
||||
char const info_simulate_version[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
|
||||
SIMULATE_VERSION_MAJOR,
|
||||
# ifdef SIMULATE_VERSION_MINOR
|
||||
'.', SIMULATE_VERSION_MINOR,
|
||||
# ifdef SIMULATE_VERSION_PATCH
|
||||
'.', SIMULATE_VERSION_PATCH,
|
||||
# ifdef SIMULATE_VERSION_TWEAK
|
||||
'.', SIMULATE_VERSION_TWEAK,
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
']','\0'};
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
|
||||
char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
|
||||
|
||||
|
||||
|
||||
#if !defined(__STDC__) && !defined(__clang__)
|
||||
# if defined(_MSC_VER) || defined(__ibmxl__) || defined(__IBMC__)
|
||||
# define C_DIALECT "90"
|
||||
# else
|
||||
# define C_DIALECT
|
||||
# endif
|
||||
#elif __STDC_VERSION__ > 201710L
|
||||
# define C_DIALECT "23"
|
||||
#elif __STDC_VERSION__ >= 201710L
|
||||
# define C_DIALECT "17"
|
||||
#elif __STDC_VERSION__ >= 201000L
|
||||
# define C_DIALECT "11"
|
||||
#elif __STDC_VERSION__ >= 199901L
|
||||
# define C_DIALECT "99"
|
||||
#else
|
||||
# define C_DIALECT "90"
|
||||
#endif
|
||||
const char* info_language_dialect_default =
|
||||
"INFO" ":" "dialect_default[" C_DIALECT "]";
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef ID_VOID_MAIN
|
||||
void main() {}
|
||||
#else
|
||||
# if defined(__CLASSIC_C__)
|
||||
int main(argc, argv) int argc; char *argv[];
|
||||
# else
|
||||
int main(int argc, char* argv[])
|
||||
# endif
|
||||
{
|
||||
int require = 0;
|
||||
require += info_compiler[argc];
|
||||
require += info_platform[argc];
|
||||
require += info_arch[argc];
|
||||
#ifdef COMPILER_VERSION_MAJOR
|
||||
require += info_version[argc];
|
||||
#endif
|
||||
#ifdef COMPILER_VERSION_INTERNAL
|
||||
require += info_version_internal[argc];
|
||||
#endif
|
||||
#ifdef SIMULATE_ID
|
||||
require += info_simulate[argc];
|
||||
#endif
|
||||
#ifdef SIMULATE_VERSION_MAJOR
|
||||
require += info_simulate_version[argc];
|
||||
#endif
|
||||
#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
|
||||
require += info_cray[argc];
|
||||
#endif
|
||||
require += info_language_dialect_default[argc];
|
||||
(void)argv;
|
||||
return require;
|
||||
}
|
||||
#endif
|
Binary file not shown.
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{CAE07175-D007-4FC3-BFE8-47B392814159}</ProjectGuid>
|
||||
<RootNamespace>CompilerIdC</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
|
||||
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
|
||||
|
||||
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup>
|
||||
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
||||
</ImportGroup>
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>
|
||||
</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
|
||||
<Link>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>for %%i in (cl.exe) do %40echo CMAKE_C_COMPILER=%%~$PATH:i</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CMakeCCompilerId.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
</ImportGroup>
|
||||
</Project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
|
||||
Debug|x64|D:\rgsj\colmap-build\CMakeFiles\3.21.0-rc1\CompilerIdC\|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,795 @@
|
||||
/* This source file must have a .cpp extension so that all C++ compilers
|
||||
recognize the extension without flags. Borland does not know .cxx for
|
||||
example. */
|
||||
#ifndef __cplusplus
|
||||
# error "A C compiler has been selected for C++."
|
||||
#endif
|
||||
|
||||
#if !defined(__has_include)
|
||||
/* If the compiler does not have __has_include, pretend the answer is
|
||||
always no. */
|
||||
# define __has_include(x) 0
|
||||
#endif
|
||||
|
||||
|
||||
/* Version number components: V=Version, R=Revision, P=Patch
|
||||
Version date components: YYYY=Year, MM=Month, DD=Day */
|
||||
|
||||
#if defined(__COMO__)
|
||||
# define COMPILER_ID "Comeau"
|
||||
/* __COMO_VERSION__ = VRR */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)
|
||||
|
||||
#elif defined(__INTEL_COMPILER) || defined(__ICC)
|
||||
# define COMPILER_ID "Intel"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# if defined(__GNUC__)
|
||||
# define SIMULATE_ID "GNU"
|
||||
# endif
|
||||
/* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later,
|
||||
except that a few beta releases use the old format with V=2021. */
|
||||
# if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
|
||||
# if defined(__INTEL_COMPILER_UPDATE)
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
|
||||
# else
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
|
||||
# endif
|
||||
# else
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE)
|
||||
/* The third version component from --version is an update index,
|
||||
but no macro is provided for it. */
|
||||
# define COMPILER_VERSION_PATCH DEC(0)
|
||||
# endif
|
||||
# if defined(__INTEL_COMPILER_BUILD_DATE)
|
||||
/* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
|
||||
# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
|
||||
# endif
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
# if defined(__GNUC__)
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
|
||||
# elif defined(__GNUG__)
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
|
||||
# endif
|
||||
# if defined(__GNUC_MINOR__)
|
||||
# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
|
||||
# endif
|
||||
# if defined(__GNUC_PATCHLEVEL__)
|
||||
# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER)
|
||||
# define COMPILER_ID "IntelLLVM"
|
||||
#if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
# define SIMULATE_ID "GNU"
|
||||
#endif
|
||||
/* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and
|
||||
* later. Look for 6 digit vs. 8 digit version number to decide encoding.
|
||||
* VVVV is no smaller than the current year when a version is released.
|
||||
*/
|
||||
#if __INTEL_LLVM_COMPILER < 1000000L
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10)
|
||||
#else
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100)
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
|
||||
#elif defined(__GNUG__)
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
|
||||
#endif
|
||||
#if defined(__GNUC_MINOR__)
|
||||
# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
|
||||
#endif
|
||||
#if defined(__GNUC_PATCHLEVEL__)
|
||||
# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
||||
#endif
|
||||
|
||||
#elif defined(__PATHCC__)
|
||||
# define COMPILER_ID "PathScale"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
|
||||
# if defined(__PATHCC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
|
||||
# define COMPILER_ID "Embarcadero"
|
||||
# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
|
||||
# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
|
||||
# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
|
||||
|
||||
#elif defined(__BORLANDC__)
|
||||
# define COMPILER_ID "Borland"
|
||||
/* __BORLANDC__ = 0xVRR */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
|
||||
# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
|
||||
|
||||
#elif defined(__WATCOMC__) && __WATCOMC__ < 1200
|
||||
# define COMPILER_ID "Watcom"
|
||||
/* __WATCOMC__ = VVRR */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
||||
# if (__WATCOMC__ % 10) > 0
|
||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# define COMPILER_ID "OpenWatcom"
|
||||
/* __WATCOMC__ = VVRP + 1100 */
|
||||
# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
||||
# if (__WATCOMC__ % 10) > 0
|
||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__SUNPRO_CC)
|
||||
# define COMPILER_ID "SunPro"
|
||||
# if __SUNPRO_CC >= 0x5100
|
||||
/* __SUNPRO_CC = 0xVRRP */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
|
||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
|
||||
# else
|
||||
/* __SUNPRO_CC = 0xVRP */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
|
||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
|
||||
# endif
|
||||
|
||||
#elif defined(__HP_aCC)
|
||||
# define COMPILER_ID "HP"
|
||||
/* __HP_aCC = VVRRPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
|
||||
|
||||
#elif defined(__DECCXX)
|
||||
# define COMPILER_ID "Compaq"
|
||||
/* __DECCXX_VER = VVRRTPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)
|
||||
|
||||
#elif defined(__IBMCPP__) && defined(__COMPILER_VER__)
|
||||
# define COMPILER_ID "zOS"
|
||||
/* __IBMCPP__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
||||
|
||||
#elif defined(__ibmxl__) && defined(__clang__)
|
||||
# define COMPILER_ID "XLClang"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
|
||||
# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
|
||||
|
||||
|
||||
#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800
|
||||
# define COMPILER_ID "XL"
|
||||
/* __IBMCPP__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
||||
|
||||
#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800
|
||||
# define COMPILER_ID "VisualAge"
|
||||
/* __IBMCPP__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
||||
|
||||
#elif defined(__NVCOMPILER)
|
||||
# define COMPILER_ID "NVHPC"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__)
|
||||
# if defined(__NVCOMPILER_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(__PGI)
|
||||
# define COMPILER_ID "PGI"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
|
||||
# if defined(__PGIC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(_CRAYC)
|
||||
# define COMPILER_ID "Cray"
|
||||
# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
|
||||
# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
|
||||
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
# define COMPILER_ID "TI"
|
||||
/* __TI_COMPILER_VERSION__ = VVVRRRPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
|
||||
# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
|
||||
|
||||
#elif defined(__CLANG_FUJITSU)
|
||||
# define COMPILER_ID "FujitsuClang"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
|
||||
# define COMPILER_VERSION_INTERNAL_STR __clang_version__
|
||||
|
||||
|
||||
#elif defined(__FUJITSU)
|
||||
# define COMPILER_ID "Fujitsu"
|
||||
# if defined(__FCC_version__)
|
||||
# define COMPILER_VERSION __FCC_version__
|
||||
# elif defined(__FCC_major__)
|
||||
# define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
|
||||
# endif
|
||||
# if defined(__fcc_version)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__fcc_version)
|
||||
# elif defined(__FCC_VERSION)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION)
|
||||
# endif
|
||||
|
||||
|
||||
#elif defined(__ghs__)
|
||||
# define COMPILER_ID "GHS"
|
||||
/* __GHS_VERSION_NUMBER = VVVVRP */
|
||||
# ifdef __GHS_VERSION_NUMBER
|
||||
# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__SCO_VERSION__)
|
||||
# define COMPILER_ID "SCO"
|
||||
|
||||
#elif defined(__ARMCC_VERSION) && !defined(__clang__)
|
||||
# define COMPILER_ID "ARMCC"
|
||||
#if __ARMCC_VERSION >= 1000000
|
||||
/* __ARMCC_VERSION = VRRPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
||||
#else
|
||||
/* __ARMCC_VERSION = VRPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
||||
#endif
|
||||
|
||||
|
||||
#elif defined(__clang__) && defined(__apple_build_version__)
|
||||
# define COMPILER_ID "AppleClang"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
|
||||
|
||||
#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION)
|
||||
# define COMPILER_ID "ARMClang"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION % 10000)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION)
|
||||
|
||||
#elif defined(__clang__) && __has_include(<hip/hip_version.h>)
|
||||
# define COMPILER_ID "ROCMClang"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# elif defined(__clang__)
|
||||
# define SIMULATE_ID "Clang"
|
||||
# elif defined(__GNUC__)
|
||||
# define SIMULATE_ID "GNU"
|
||||
# endif
|
||||
# if defined(__clang__) && __has_include(<hip/hip_version.h>)
|
||||
# include <hip/hip_version.h>
|
||||
# define COMPILER_VERSION_MAJOR DEC(HIP_VERSION_MAJOR)
|
||||
# define COMPILER_VERSION_MINOR DEC(HIP_VERSION_MINOR)
|
||||
# define COMPILER_VERSION_PATCH DEC(HIP_VERSION_PATCH)
|
||||
# endif
|
||||
|
||||
#elif defined(__clang__)
|
||||
# define COMPILER_ID "Clang"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
|
||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
||||
# define COMPILER_ID "GNU"
|
||||
# if defined(__GNUC__)
|
||||
# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
|
||||
# else
|
||||
# define COMPILER_VERSION_MAJOR DEC(__GNUG__)
|
||||
# endif
|
||||
# if defined(__GNUC_MINOR__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
|
||||
# endif
|
||||
# if defined(__GNUC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# define COMPILER_ID "MSVC"
|
||||
/* _MSC_VER = VVRR */
|
||||
# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# if defined(_MSC_FULL_VER)
|
||||
# if _MSC_VER >= 1400
|
||||
/* _MSC_FULL_VER = VVRRPPPPP */
|
||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
|
||||
# else
|
||||
/* _MSC_FULL_VER = VVRRPPPP */
|
||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
|
||||
# endif
|
||||
# endif
|
||||
# if defined(_MSC_BUILD)
|
||||
# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
|
||||
# endif
|
||||
|
||||
#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
|
||||
# define COMPILER_ID "ADSP"
|
||||
#if defined(__VISUALDSPVERSION__)
|
||||
/* __VISUALDSPVERSION__ = 0xVVRRPP00 */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
|
||||
# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
|
||||
#endif
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
|
||||
# define COMPILER_ID "IAR"
|
||||
# if defined(__VER__) && defined(__ICCARM__)
|
||||
# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
|
||||
# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
|
||||
# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__))
|
||||
# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
|
||||
# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
|
||||
# endif
|
||||
|
||||
|
||||
/* These compilers are either not known or too old to define an
|
||||
identification macro. Try to identify the platform and guess that
|
||||
it is the native compiler. */
|
||||
#elif defined(__hpux) || defined(__hpua)
|
||||
# define COMPILER_ID "HP"
|
||||
|
||||
#else /* unknown compiler */
|
||||
# define COMPILER_ID ""
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
|
||||
#ifdef SIMULATE_ID
|
||||
char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
|
||||
#endif
|
||||
|
||||
#ifdef __QNXNTO__
|
||||
char const* qnxnto = "INFO" ":" "qnxnto[]";
|
||||
#endif
|
||||
|
||||
#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
|
||||
char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
|
||||
#endif
|
||||
|
||||
#define STRINGIFY_HELPER(X) #X
|
||||
#define STRINGIFY(X) STRINGIFY_HELPER(X)
|
||||
|
||||
/* Identify known platforms by name. */
|
||||
#if defined(__linux) || defined(__linux__) || defined(linux)
|
||||
# define PLATFORM_ID "Linux"
|
||||
|
||||
#elif defined(__MSYS__)
|
||||
# define PLATFORM_ID "MSYS"
|
||||
|
||||
#elif defined(__CYGWIN__)
|
||||
# define PLATFORM_ID "Cygwin"
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# define PLATFORM_ID "MinGW"
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
# define PLATFORM_ID "Darwin"
|
||||
|
||||
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
||||
# define PLATFORM_ID "Windows"
|
||||
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD)
|
||||
# define PLATFORM_ID "FreeBSD"
|
||||
|
||||
#elif defined(__NetBSD__) || defined(__NetBSD)
|
||||
# define PLATFORM_ID "NetBSD"
|
||||
|
||||
#elif defined(__OpenBSD__) || defined(__OPENBSD)
|
||||
# define PLATFORM_ID "OpenBSD"
|
||||
|
||||
#elif defined(__sun) || defined(sun)
|
||||
# define PLATFORM_ID "SunOS"
|
||||
|
||||
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
|
||||
# define PLATFORM_ID "AIX"
|
||||
|
||||
#elif defined(__hpux) || defined(__hpux__)
|
||||
# define PLATFORM_ID "HP-UX"
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
# define PLATFORM_ID "Haiku"
|
||||
|
||||
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
|
||||
# define PLATFORM_ID "BeOS"
|
||||
|
||||
#elif defined(__QNX__) || defined(__QNXNTO__)
|
||||
# define PLATFORM_ID "QNX"
|
||||
|
||||
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
|
||||
# define PLATFORM_ID "Tru64"
|
||||
|
||||
#elif defined(__riscos) || defined(__riscos__)
|
||||
# define PLATFORM_ID "RISCos"
|
||||
|
||||
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
|
||||
# define PLATFORM_ID "SINIX"
|
||||
|
||||
#elif defined(__UNIX_SV__)
|
||||
# define PLATFORM_ID "UNIX_SV"
|
||||
|
||||
#elif defined(__bsdos__)
|
||||
# define PLATFORM_ID "BSDOS"
|
||||
|
||||
#elif defined(_MPRAS) || defined(MPRAS)
|
||||
# define PLATFORM_ID "MP-RAS"
|
||||
|
||||
#elif defined(__osf) || defined(__osf__)
|
||||
# define PLATFORM_ID "OSF1"
|
||||
|
||||
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
|
||||
# define PLATFORM_ID "SCO_SV"
|
||||
|
||||
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
|
||||
# define PLATFORM_ID "ULTRIX"
|
||||
|
||||
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
|
||||
# define PLATFORM_ID "Xenix"
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(__LINUX__)
|
||||
# define PLATFORM_ID "Linux"
|
||||
|
||||
# elif defined(__DOS__)
|
||||
# define PLATFORM_ID "DOS"
|
||||
|
||||
# elif defined(__OS2__)
|
||||
# define PLATFORM_ID "OS2"
|
||||
|
||||
# elif defined(__WINDOWS__)
|
||||
# define PLATFORM_ID "Windows3x"
|
||||
|
||||
# elif defined(__VXWORKS__)
|
||||
# define PLATFORM_ID "VxWorks"
|
||||
|
||||
# else /* unknown platform */
|
||||
# define PLATFORM_ID
|
||||
# endif
|
||||
|
||||
#elif defined(__INTEGRITY)
|
||||
# if defined(INT_178B)
|
||||
# define PLATFORM_ID "Integrity178"
|
||||
|
||||
# else /* regular Integrity */
|
||||
# define PLATFORM_ID "Integrity"
|
||||
# endif
|
||||
|
||||
#else /* unknown platform */
|
||||
# define PLATFORM_ID
|
||||
|
||||
#endif
|
||||
|
||||
/* For windows compilers MSVC and Intel we can determine
|
||||
the architecture of the compiler being used. This is because
|
||||
the compilers do not have flags that can change the architecture,
|
||||
but rather depend on which compiler is being used
|
||||
*/
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
# if defined(_M_IA64)
|
||||
# define ARCHITECTURE_ID "IA64"
|
||||
|
||||
# elif defined(_M_ARM64EC)
|
||||
# define ARCHITECTURE_ID "ARM64EC"
|
||||
|
||||
# elif defined(_M_X64) || defined(_M_AMD64)
|
||||
# define ARCHITECTURE_ID "x64"
|
||||
|
||||
# elif defined(_M_IX86)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# elif defined(_M_ARM64)
|
||||
# define ARCHITECTURE_ID "ARM64"
|
||||
|
||||
# elif defined(_M_ARM)
|
||||
# if _M_ARM == 4
|
||||
# define ARCHITECTURE_ID "ARMV4I"
|
||||
# elif _M_ARM == 5
|
||||
# define ARCHITECTURE_ID "ARMV5I"
|
||||
# else
|
||||
# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
|
||||
# endif
|
||||
|
||||
# elif defined(_M_MIPS)
|
||||
# define ARCHITECTURE_ID "MIPS"
|
||||
|
||||
# elif defined(_M_SH)
|
||||
# define ARCHITECTURE_ID "SHx"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(_M_I86)
|
||||
# define ARCHITECTURE_ID "I86"
|
||||
|
||||
# elif defined(_M_IX86)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
|
||||
# if defined(__ICCARM__)
|
||||
# define ARCHITECTURE_ID "ARM"
|
||||
|
||||
# elif defined(__ICCRX__)
|
||||
# define ARCHITECTURE_ID "RX"
|
||||
|
||||
# elif defined(__ICCRH850__)
|
||||
# define ARCHITECTURE_ID "RH850"
|
||||
|
||||
# elif defined(__ICCRL78__)
|
||||
# define ARCHITECTURE_ID "RL78"
|
||||
|
||||
# elif defined(__ICCRISCV__)
|
||||
# define ARCHITECTURE_ID "RISCV"
|
||||
|
||||
# elif defined(__ICCAVR__)
|
||||
# define ARCHITECTURE_ID "AVR"
|
||||
|
||||
# elif defined(__ICC430__)
|
||||
# define ARCHITECTURE_ID "MSP430"
|
||||
|
||||
# elif defined(__ICCV850__)
|
||||
# define ARCHITECTURE_ID "V850"
|
||||
|
||||
# elif defined(__ICC8051__)
|
||||
# define ARCHITECTURE_ID "8051"
|
||||
|
||||
# elif defined(__ICCSTM8__)
|
||||
# define ARCHITECTURE_ID "STM8"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__ghs__)
|
||||
# if defined(__PPC64__)
|
||||
# define ARCHITECTURE_ID "PPC64"
|
||||
|
||||
# elif defined(__ppc__)
|
||||
# define ARCHITECTURE_ID "PPC"
|
||||
|
||||
# elif defined(__ARM__)
|
||||
# define ARCHITECTURE_ID "ARM"
|
||||
|
||||
# elif defined(__x86_64__)
|
||||
# define ARCHITECTURE_ID "x64"
|
||||
|
||||
# elif defined(__i386__)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
# if defined(__TI_ARM__)
|
||||
# define ARCHITECTURE_ID "ARM"
|
||||
|
||||
# elif defined(__MSP430__)
|
||||
# define ARCHITECTURE_ID "MSP430"
|
||||
|
||||
# elif defined(__TMS320C28XX__)
|
||||
# define ARCHITECTURE_ID "TMS320C28x"
|
||||
|
||||
# elif defined(__TMS320C6X__) || defined(_TMS320C6X)
|
||||
# define ARCHITECTURE_ID "TMS320C6x"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#else
|
||||
# define ARCHITECTURE_ID
|
||||
#endif
|
||||
|
||||
/* Convert integer to decimal digit literals. */
|
||||
#define DEC(n) \
|
||||
('0' + (((n) / 10000000)%10)), \
|
||||
('0' + (((n) / 1000000)%10)), \
|
||||
('0' + (((n) / 100000)%10)), \
|
||||
('0' + (((n) / 10000)%10)), \
|
||||
('0' + (((n) / 1000)%10)), \
|
||||
('0' + (((n) / 100)%10)), \
|
||||
('0' + (((n) / 10)%10)), \
|
||||
('0' + ((n) % 10))
|
||||
|
||||
/* Convert integer to hex digit literals. */
|
||||
#define HEX(n) \
|
||||
('0' + ((n)>>28 & 0xF)), \
|
||||
('0' + ((n)>>24 & 0xF)), \
|
||||
('0' + ((n)>>20 & 0xF)), \
|
||||
('0' + ((n)>>16 & 0xF)), \
|
||||
('0' + ((n)>>12 & 0xF)), \
|
||||
('0' + ((n)>>8 & 0xF)), \
|
||||
('0' + ((n)>>4 & 0xF)), \
|
||||
('0' + ((n) & 0xF))
|
||||
|
||||
/* Construct a string literal encoding the version number. */
|
||||
#ifdef COMPILER_VERSION
|
||||
char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]";
|
||||
|
||||
/* Construct a string literal encoding the version number components. */
|
||||
#elif defined(COMPILER_VERSION_MAJOR)
|
||||
char const info_version[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
|
||||
COMPILER_VERSION_MAJOR,
|
||||
# ifdef COMPILER_VERSION_MINOR
|
||||
'.', COMPILER_VERSION_MINOR,
|
||||
# ifdef COMPILER_VERSION_PATCH
|
||||
'.', COMPILER_VERSION_PATCH,
|
||||
# ifdef COMPILER_VERSION_TWEAK
|
||||
'.', COMPILER_VERSION_TWEAK,
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
']','\0'};
|
||||
#endif
|
||||
|
||||
/* Construct a string literal encoding the internal version number. */
|
||||
#ifdef COMPILER_VERSION_INTERNAL
|
||||
char const info_version_internal[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
|
||||
'i','n','t','e','r','n','a','l','[',
|
||||
COMPILER_VERSION_INTERNAL,']','\0'};
|
||||
#elif defined(COMPILER_VERSION_INTERNAL_STR)
|
||||
char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]";
|
||||
#endif
|
||||
|
||||
/* Construct a string literal encoding the version number components. */
|
||||
#ifdef SIMULATE_VERSION_MAJOR
|
||||
char const info_simulate_version[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
|
||||
SIMULATE_VERSION_MAJOR,
|
||||
# ifdef SIMULATE_VERSION_MINOR
|
||||
'.', SIMULATE_VERSION_MINOR,
|
||||
# ifdef SIMULATE_VERSION_PATCH
|
||||
'.', SIMULATE_VERSION_PATCH,
|
||||
# ifdef SIMULATE_VERSION_TWEAK
|
||||
'.', SIMULATE_VERSION_TWEAK,
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
']','\0'};
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
|
||||
char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
|
||||
|
||||
|
||||
|
||||
#if defined(__INTEL_COMPILER) && defined(_MSVC_LANG) && _MSVC_LANG < 201403L
|
||||
# if defined(__INTEL_CXX11_MODE__)
|
||||
# if defined(__cpp_aggregate_nsdmi)
|
||||
# define CXX_STD 201402L
|
||||
# else
|
||||
# define CXX_STD 201103L
|
||||
# endif
|
||||
# else
|
||||
# define CXX_STD 199711L
|
||||
# endif
|
||||
#elif defined(_MSC_VER) && defined(_MSVC_LANG)
|
||||
# define CXX_STD _MSVC_LANG
|
||||
#else
|
||||
# define CXX_STD __cplusplus
|
||||
#endif
|
||||
|
||||
const char* info_language_dialect_default = "INFO" ":" "dialect_default["
|
||||
#if CXX_STD > 202002L
|
||||
"23"
|
||||
#elif CXX_STD > 201703L
|
||||
"20"
|
||||
#elif CXX_STD >= 201703L
|
||||
"17"
|
||||
#elif CXX_STD >= 201402L
|
||||
"14"
|
||||
#elif CXX_STD >= 201103L
|
||||
"11"
|
||||
#else
|
||||
"98"
|
||||
#endif
|
||||
"]";
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int require = 0;
|
||||
require += info_compiler[argc];
|
||||
require += info_platform[argc];
|
||||
#ifdef COMPILER_VERSION_MAJOR
|
||||
require += info_version[argc];
|
||||
#endif
|
||||
#ifdef COMPILER_VERSION_INTERNAL
|
||||
require += info_version_internal[argc];
|
||||
#endif
|
||||
#ifdef SIMULATE_ID
|
||||
require += info_simulate[argc];
|
||||
#endif
|
||||
#ifdef SIMULATE_VERSION_MAJOR
|
||||
require += info_simulate_version[argc];
|
||||
#endif
|
||||
#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
|
||||
require += info_cray[argc];
|
||||
#endif
|
||||
require += info_language_dialect_default[argc];
|
||||
(void)argv;
|
||||
return require;
|
||||
}
|
Binary file not shown.
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{CAE07175-D007-4FC3-BFE8-47B392814159}</ProjectGuid>
|
||||
<RootNamespace>CompilerIdCXX</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
|
||||
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
|
||||
|
||||
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup>
|
||||
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
||||
</ImportGroup>
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>
|
||||
</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
|
||||
<Link>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>for %%i in (cl.exe) do %40echo CMAKE_CXX_COMPILER=%%~$PATH:i</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CMakeCXXCompilerId.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
</ImportGroup>
|
||||
</Project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
|
||||
Debug|x64|D:\rgsj\colmap-build\CMakeFiles\3.21.0-rc1\CompilerIdCXX\|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
D:/vss/Common7/IDE/VC/VCTargets
|
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{F3FC6D86-508D-3FB1-96D2-995F08B142EC}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<Platform>x64</Platform>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<ConfigurationType>Utility</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
|
||||
<ItemDefinitionGroup>
|
||||
<PostBuildEvent>
|
||||
<Command>echo VCTargetsPath=$(VCTargetsPath)</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
||||
</Project>
|
@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
|
||||
Debug|x64|D:\rgsj\colmap-build\CMakeFiles\3.21.0-rc1\|
|
@ -0,0 +1,17 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <omp.h>
|
||||
const char ompver_str[] = { 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'M',
|
||||
'P', '-', 'd', 'a', 't', 'e', '[',
|
||||
('0' + ((_OPENMP/100000)%10)),
|
||||
('0' + ((_OPENMP/10000)%10)),
|
||||
('0' + ((_OPENMP/1000)%10)),
|
||||
('0' + ((_OPENMP/100)%10)),
|
||||
('0' + ((_OPENMP/10)%10)),
|
||||
('0' + ((_OPENMP/1)%10)),
|
||||
']', '\0' };
|
||||
int main(void)
|
||||
{
|
||||
puts(ompver_str);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <omp.h>
|
||||
const char ompver_str[] = { 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'M',
|
||||
'P', '-', 'd', 'a', 't', 'e', '[',
|
||||
('0' + ((_OPENMP/100000)%10)),
|
||||
('0' + ((_OPENMP/10000)%10)),
|
||||
('0' + ((_OPENMP/1000)%10)),
|
||||
('0' + ((_OPENMP/100)%10)),
|
||||
('0' + ((_OPENMP/10)%10)),
|
||||
('0' + ((_OPENMP/1)%10)),
|
||||
']', '\0' };
|
||||
int main(void)
|
||||
{
|
||||
puts(ompver_str);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
|
||||
#include <omp.h>
|
||||
int main(void) {
|
||||
#ifdef _OPENMP
|
||||
omp_get_max_threads();
|
||||
return 0;
|
||||
#elif defined(__HIP_DEVICE_COMPILE__)
|
||||
return 0;
|
||||
#else
|
||||
breaks_on_purpose
|
||||
#endif
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
|
||||
#include <omp.h>
|
||||
int main(void) {
|
||||
#ifdef _OPENMP
|
||||
omp_get_max_threads();
|
||||
return 0;
|
||||
#elif defined(__HIP_DEVICE_COMPILE__)
|
||||
return 0;
|
||||
#else
|
||||
breaks_on_purpose
|
||||
#endif
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -0,0 +1,214 @@
|
||||
// ==========================================================
|
||||
// Batch loader
|
||||
//
|
||||
// Design and implementation by
|
||||
// - Floris van den Berg
|
||||
// - Hervé Drolon
|
||||
//
|
||||
// This file is part of FreeImage 3
|
||||
//
|
||||
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
|
||||
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
|
||||
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
|
||||
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
|
||||
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
|
||||
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
|
||||
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
|
||||
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
|
||||
// THIS DISCLAIMER.
|
||||
//
|
||||
// Use at own risk!
|
||||
// ==========================================================
|
||||
|
||||
//
|
||||
// This example shows how to easily batch load a directory
|
||||
// full of images. Because not all formats can be identified
|
||||
// by their header (some images don't have a header or one
|
||||
// at the end of the file) we make use of the
|
||||
// FreeImage_GetFIFFromFilename function. This function
|
||||
// receives a file name, for example 'myfile.bmp', and returns
|
||||
// a FREE_IMAGE_TYPE enum which identifies that bitmap.
|
||||
//
|
||||
// Functions used in this sample :
|
||||
// FreeImage_GetFileType, FreeImage_GetFIFFromFilename, FreeImage_FIFSupportsReading,
|
||||
// FreeImage_Load, FreeImage_GetBPP, FreeImage_FIFSupportsWriting, FreeImage_GetFormatFromFIF
|
||||
// FreeImage_FIFSupportsExportBPP, FreeImage_Save, FreeImage_Unload,
|
||||
// FreeImage_SetOutputMessage, FreeImage_GetVersion, FreeImage_GetCopyrightMessage
|
||||
//
|
||||
// ==========================================================
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "FreeImage.h"
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/** Generic image loader
|
||||
@param lpszPathName Pointer to the full file name
|
||||
@param flag Optional load flag constant
|
||||
@return Returns the loaded dib if successful, returns NULL otherwise
|
||||
*/
|
||||
FIBITMAP* GenericLoader(const char* lpszPathName, int flag) {
|
||||
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
|
||||
|
||||
// check the file signature and deduce its format
|
||||
// (the second argument is currently not used by FreeImage)
|
||||
fif = FreeImage_GetFileType(lpszPathName, 0);
|
||||
if(fif == FIF_UNKNOWN) {
|
||||
// no signature ?
|
||||
// try to guess the file format from the file extension
|
||||
fif = FreeImage_GetFIFFromFilename(lpszPathName);
|
||||
}
|
||||
// check that the plugin has reading capabilities ...
|
||||
if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {
|
||||
// ok, let's load the file
|
||||
FIBITMAP *dib = FreeImage_Load(fif, lpszPathName, flag);
|
||||
// unless a bad file format, we are done !
|
||||
return dib;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Generic image writer
|
||||
@param dib Pointer to the dib to be saved
|
||||
@param lpszPathName Pointer to the full file name
|
||||
@param flag Optional save flag constant
|
||||
@return Returns true if successful, returns false otherwise
|
||||
*/
|
||||
bool GenericWriter(FIBITMAP* dib, const char* lpszPathName, int flag) {
|
||||
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
|
||||
BOOL bSuccess = FALSE;
|
||||
|
||||
if(dib) {
|
||||
// try to guess the file format from the file extension
|
||||
fif = FreeImage_GetFIFFromFilename(lpszPathName);
|
||||
if(fif != FIF_UNKNOWN ) {
|
||||
// check that the plugin has sufficient writing and export capabilities ...
|
||||
WORD bpp = FreeImage_GetBPP(dib);
|
||||
if(FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp)) {
|
||||
// ok, we can save the file
|
||||
bSuccess = FreeImage_Save(fif, dib, lpszPathName, flag);
|
||||
// unless an abnormal bug, we are done !
|
||||
}
|
||||
}
|
||||
}
|
||||
return (bSuccess == TRUE) ? true : false;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
FreeImage error handler
|
||||
@param fif Format / Plugin responsible for the error
|
||||
@param message Error message
|
||||
*/
|
||||
void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) {
|
||||
printf("\n*** ");
|
||||
if(fif != FIF_UNKNOWN) {
|
||||
printf("%s Format\n", FreeImage_GetFormatFromFIF(fif));
|
||||
}
|
||||
printf(message);
|
||||
printf(" ***\n");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 260
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
|
||||
const char *input_dir = "d:\\images\\";
|
||||
FIBITMAP *dib = NULL;
|
||||
int id = 1;
|
||||
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_Initialise();
|
||||
#endif // FREEIMAGE_LIB
|
||||
|
||||
// initialize your own FreeImage error handler
|
||||
|
||||
FreeImage_SetOutputMessage(FreeImageErrorHandler);
|
||||
|
||||
// print version & copyright infos
|
||||
|
||||
printf(FreeImage_GetVersion());
|
||||
printf("\n");
|
||||
printf(FreeImage_GetCopyrightMessage());
|
||||
printf("\n");
|
||||
|
||||
// open the log file
|
||||
|
||||
FILE *log_file = fopen("log_file.txt", "w");
|
||||
|
||||
// batch convert all supported bitmaps
|
||||
|
||||
_finddata_t finddata;
|
||||
long handle;
|
||||
char image_path[MAX_PATH];
|
||||
|
||||
// scan all files
|
||||
strcpy(image_path, input_dir);
|
||||
strcat(image_path, "*.*");
|
||||
|
||||
if ((handle = _findfirst(image_path, &finddata)) != -1) {
|
||||
do {
|
||||
// make a path to a directory
|
||||
|
||||
char *directory = new char[MAX_PATH];
|
||||
strcpy(directory, input_dir);
|
||||
strcat(directory, finddata.name);
|
||||
|
||||
// make a unique filename
|
||||
|
||||
char *unique = new char[128];
|
||||
itoa(id, unique, 10);
|
||||
strcat(unique, ".png");
|
||||
|
||||
// open and load the file using the default load option
|
||||
dib = GenericLoader(directory, 0);
|
||||
|
||||
if (dib != NULL) {
|
||||
// save the file as PNG
|
||||
bool bSuccess = GenericWriter(dib, unique, PNG_DEFAULT);
|
||||
|
||||
// free the dib
|
||||
FreeImage_Unload(dib);
|
||||
|
||||
if(bSuccess) {
|
||||
fwrite(unique, strlen(unique), 1, log_file);
|
||||
} else {
|
||||
strcpy(unique, "FAILED");
|
||||
fwrite(unique, strlen(unique), 1, log_file);
|
||||
}
|
||||
fwrite(" >> ", 4, 1, log_file);
|
||||
fwrite(directory, strlen(directory), 1, log_file);
|
||||
fwrite("\n", 1, 1, log_file);
|
||||
|
||||
id++;
|
||||
}
|
||||
|
||||
delete [] unique;
|
||||
delete [] directory;
|
||||
|
||||
} while (_findnext(handle, &finddata) == 0);
|
||||
|
||||
_findclose(handle);
|
||||
}
|
||||
|
||||
fclose(log_file);
|
||||
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_DeInitialise();
|
||||
#endif // FREEIMAGE_LIB
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
// ==========================================================
|
||||
// Multipage functions demonstration
|
||||
//
|
||||
// Design and implementation by
|
||||
// - Hervé Drolon
|
||||
//
|
||||
// This file is part of FreeImage 3
|
||||
//
|
||||
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
|
||||
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
|
||||
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
|
||||
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
|
||||
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
|
||||
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
|
||||
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
|
||||
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
|
||||
// THIS DISCLAIMER.
|
||||
//
|
||||
// Use at own risk!
|
||||
// ==========================================================
|
||||
|
||||
// This sample shows how to clone a multipage TIFF
|
||||
//
|
||||
// Functions used in this sample :
|
||||
// FreeImage_OpenMultiBitmap, FreeImage_GetPageCount, FreeImage_LockPage,
|
||||
// FreeImage_AppendPage, FreeImage_UnlockPage, FreeImage_CloseMultiBitmap;
|
||||
// FreeImage_SetOutputMessage
|
||||
//
|
||||
// ==========================================================
|
||||
|
||||
#include <iostream.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "FreeImage.h"
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
FreeImage error handler
|
||||
*/
|
||||
void MyMessageFunc(FREE_IMAGE_FORMAT fif, const char *message) {
|
||||
cout << "\n*** " << message << " ***\n";
|
||||
cout.flush();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
bool CloneMultiPage(FREE_IMAGE_FORMAT fif, char *input, char *output, int output_flag) {
|
||||
|
||||
BOOL bMemoryCache = TRUE;
|
||||
|
||||
// Open src file (read-only, use memory cache)
|
||||
FIMULTIBITMAP *src = FreeImage_OpenMultiBitmap(fif, input, FALSE, TRUE, bMemoryCache);
|
||||
|
||||
if(src) {
|
||||
// Open dst file (creation, use memory cache)
|
||||
FIMULTIBITMAP *dst = FreeImage_OpenMultiBitmap(fif, output, TRUE, FALSE, bMemoryCache);
|
||||
|
||||
// Get src page count
|
||||
int count = FreeImage_GetPageCount(src);
|
||||
|
||||
// Clone src to dst
|
||||
for(int page = 0; page < count; page++) {
|
||||
// Load the bitmap at position 'page'
|
||||
FIBITMAP *dib = FreeImage_LockPage(src, page);
|
||||
if(dib) {
|
||||
// add a new bitmap to dst
|
||||
FreeImage_AppendPage(dst, dib);
|
||||
// Unload the bitmap (do not apply any change to src)
|
||||
FreeImage_UnlockPage(src, dib, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
// Close src
|
||||
FreeImage_CloseMultiBitmap(src, 0);
|
||||
// Save and close dst
|
||||
FreeImage_CloseMultiBitmap(dst, output_flag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
|
||||
char *input_filename = "images\\input.tif";
|
||||
char *output_filename = "images\\clone.tif";
|
||||
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_Initialise();
|
||||
#endif // FREEIMAGE_LIB
|
||||
|
||||
// initialize our own FreeImage error handler
|
||||
|
||||
FreeImage_SetOutputMessage(MyMessageFunc);
|
||||
|
||||
// Copy 'input.tif' to 'clone.tif'
|
||||
|
||||
CloneMultiPage(FIF_TIFF, input_filename, output_filename, 0);
|
||||
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_DeInitialise();
|
||||
#endif // FREEIMAGE_LIB
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
// ==========================================================
|
||||
// Alpha channel manipulation example
|
||||
//
|
||||
// Design and implementation by
|
||||
// - Hervé Drolon
|
||||
//
|
||||
// This file is part of FreeImage 3
|
||||
//
|
||||
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
|
||||
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
|
||||
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
|
||||
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
|
||||
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
|
||||
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
|
||||
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
|
||||
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
|
||||
// THIS DISCLAIMER.
|
||||
//
|
||||
// Use at own risk!
|
||||
// ==========================================================
|
||||
|
||||
// This example shows how to create a transparent image from any input image
|
||||
// using the greyscale version of the input image as the alpha channel mask.
|
||||
// The alpha channel is set using the FreeImage_SetChannel function.
|
||||
//
|
||||
//
|
||||
// ==========================================================
|
||||
|
||||
#include <stdio.h>
|
||||
#include "FreeImage.h"
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/** Generic image loader
|
||||
@param lpszPathName Pointer to the full file name
|
||||
@param flag Optional load flag constant
|
||||
@return Returns the loaded dib if successful, returns NULL otherwise
|
||||
*/
|
||||
FIBITMAP* GenericLoader(const char* lpszPathName, int flag) {
|
||||
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
|
||||
|
||||
// check the file signature and deduce its format
|
||||
// (the second argument is currently not used by FreeImage)
|
||||
fif = FreeImage_GetFileType(lpszPathName, 0);
|
||||
if(fif == FIF_UNKNOWN) {
|
||||
// no signature ?
|
||||
// try to guess the file format from the file extension
|
||||
fif = FreeImage_GetFIFFromFilename(lpszPathName);
|
||||
}
|
||||
// check that the plugin has reading capabilities ...
|
||||
if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {
|
||||
// ok, let's load the file
|
||||
FIBITMAP *dib = FreeImage_Load(fif, lpszPathName, flag);
|
||||
// unless a bad file format, we are done !
|
||||
return dib;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Generic image writer
|
||||
@param dib Pointer to the dib to be saved
|
||||
@param lpszPathName Pointer to the full file name
|
||||
@param flag Optional save flag constant
|
||||
@return Returns true if successful, returns false otherwise
|
||||
*/
|
||||
bool GenericWriter(FIBITMAP* dib, const char* lpszPathName, int flag) {
|
||||
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
|
||||
BOOL bSuccess = FALSE;
|
||||
|
||||
if(dib) {
|
||||
// try to guess the file format from the file extension
|
||||
fif = FreeImage_GetFIFFromFilename(lpszPathName);
|
||||
if(fif != FIF_UNKNOWN ) {
|
||||
// check that the plugin has sufficient writing and export capabilities ...
|
||||
WORD bpp = FreeImage_GetBPP(dib);
|
||||
if(FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp)) {
|
||||
// ok, we can save the file
|
||||
bSuccess = FreeImage_Save(fif, dib, lpszPathName, flag);
|
||||
// unless an abnormal bug, we are done !
|
||||
}
|
||||
}
|
||||
}
|
||||
return (bSuccess == TRUE) ? true : false;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
FreeImage error handler
|
||||
@param fif Format / Plugin responsible for the error
|
||||
@param message Error message
|
||||
*/
|
||||
void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) {
|
||||
printf("\n*** ");
|
||||
if(fif != FIF_UNKNOWN) {
|
||||
printf("%s Format\n", FreeImage_GetFormatFromFIF(fif));
|
||||
}
|
||||
printf(message);
|
||||
printf(" ***\n");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
Creates a 32-bit transparent image using the black channel of the source image
|
||||
@param src Source image
|
||||
@return Returns a 32-bit transparent image
|
||||
*/
|
||||
FIBITMAP* CreateAlphaFromLightness(FIBITMAP *src) {
|
||||
// create a 32-bit image from the source
|
||||
FIBITMAP *dst = FreeImage_ConvertTo32Bits(src);
|
||||
|
||||
// create a 8-bit mask
|
||||
FreeImage_Invert(src);
|
||||
FIBITMAP *mask = FreeImage_ConvertTo8Bits(src);
|
||||
FreeImage_Invert(src);
|
||||
|
||||
// insert the mask as an alpha channel
|
||||
FreeImage_SetChannel(dst, mask, FICC_ALPHA);
|
||||
|
||||
// free the mask and return
|
||||
FreeImage_Unload(mask);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_Initialise();
|
||||
#endif // FREEIMAGE_LIB
|
||||
|
||||
// initialize your own FreeImage error handler
|
||||
|
||||
FreeImage_SetOutputMessage(FreeImageErrorHandler);
|
||||
|
||||
// print version & copyright infos
|
||||
|
||||
printf("FreeImage version : %s", FreeImage_GetVersion());
|
||||
printf("\n");
|
||||
printf(FreeImage_GetCopyrightMessage());
|
||||
printf("\n");
|
||||
|
||||
|
||||
if(argc != 3) {
|
||||
printf("Usage : CreateAlpha <input file name> <output file name>\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Load the source image
|
||||
FIBITMAP *src = GenericLoader(argv[1], 0);
|
||||
if(src) {
|
||||
// Create a transparent image from the lightness image of src
|
||||
FIBITMAP *dst = CreateAlphaFromLightness(src);
|
||||
|
||||
if(dst) {
|
||||
// Save the destination image
|
||||
bool bSuccess = GenericWriter(dst, argv[2], 0);
|
||||
if(!bSuccess) {
|
||||
printf("\nUnable to save %s file", argv[2]);
|
||||
printf("\nThis format does not support 32-bit images");
|
||||
}
|
||||
|
||||
// Free dst
|
||||
FreeImage_Unload(dst);
|
||||
}
|
||||
|
||||
// Free src
|
||||
FreeImage_Unload(src);
|
||||
}
|
||||
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_DeInitialise();
|
||||
#endif // FREEIMAGE_LIB
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
// ==========================================================
|
||||
// Plugin functions demonstration
|
||||
//
|
||||
// Design and implementation by
|
||||
// - Hervé Drolon
|
||||
//
|
||||
// This file is part of FreeImage 3
|
||||
//
|
||||
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
|
||||
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
|
||||
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
|
||||
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
|
||||
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
|
||||
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
|
||||
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
|
||||
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
|
||||
// THIS DISCLAIMER.
|
||||
//
|
||||
// Use at own risk!
|
||||
// ==========================================================
|
||||
|
||||
// This example shows how to use Plugin functions to explore FreeImage capabilities.
|
||||
// Whenever an external plugin is added to the library, it is automatically loaded
|
||||
// with FreeImage and can be asked for its capabilities via the plugin functions.
|
||||
//
|
||||
// Functions used in this sample :
|
||||
// FreeImage_FIFSupportsExportBPP, FreeImage_FIFSupportsICCProfiles, FreeImage_FIFSupportsReading,
|
||||
// FreeImage_FIFSupportsWriting, FreeImage_GetFIFCount, FreeImage_GetFIFDescription,
|
||||
// FreeImage_GetFIFExtensionList, FreeImage_GetFormatFromFIF,
|
||||
// FreeImage_GetVersion, FreeImage_GetCopyrightMessage, FreeImage_SetOutputMessage
|
||||
//
|
||||
// ==========================================================
|
||||
|
||||
#include <iostream.h>
|
||||
#include <fstream.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "FreeImage.h"
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
FreeImage error handler
|
||||
*/
|
||||
void MyMessageFunc(FREE_IMAGE_FORMAT fif, const char *message) {
|
||||
cout << "\n*** " << message << " ***\n";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Print plugins import capabilities
|
||||
*/
|
||||
void PrintImportFormats(iostream& ios) {
|
||||
int count = FreeImage_GetFIFCount();
|
||||
if(count)
|
||||
ios << "FORMAT;DESCRIPTION;EXTENSIONS;ICC PROFILES\n";
|
||||
for(int i = 0; i < count; i++) {
|
||||
FREE_IMAGE_FORMAT fif = (FREE_IMAGE_FORMAT)i;
|
||||
|
||||
if(FreeImage_FIFSupportsReading(fif)) {
|
||||
const char * format = FreeImage_GetFormatFromFIF(fif);
|
||||
const char * description = FreeImage_GetFIFDescription(fif);
|
||||
const char * ext = FreeImage_GetFIFExtensionList(fif);
|
||||
const char * icc = "*";
|
||||
if(FreeImage_FIFSupportsICCProfiles(fif)) {
|
||||
ios << format << ";" << description << ";" << ext << ";" << icc << "\n";
|
||||
} else {
|
||||
ios << format << ";" << description << ";" << ext << "; \n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Print plugins export capabilities
|
||||
*/
|
||||
void PrintExportFormats(iostream& ios) {
|
||||
int count = FreeImage_GetFIFCount();
|
||||
if(count)
|
||||
ios << "FORMAT;DESCRIPTION;EXTENSIONS;BITDEPTH;ICC PROFILES\n";
|
||||
for(int i = 0; i < count; i++) {
|
||||
FREE_IMAGE_FORMAT fif = (FREE_IMAGE_FORMAT)i;
|
||||
|
||||
if(FreeImage_FIFSupportsWriting(fif)) {
|
||||
const char * format = FreeImage_GetFormatFromFIF(fif);
|
||||
const char * description = FreeImage_GetFIFDescription(fif);
|
||||
const char * ext = FreeImage_GetFIFExtensionList(fif);
|
||||
const char * icc = "*";
|
||||
|
||||
ios << format << ";" << description << ";" << ext << ";";
|
||||
if(FreeImage_FIFSupportsExportBPP(fif, 1))
|
||||
ios << "1 ";
|
||||
if(FreeImage_FIFSupportsExportBPP(fif, 4))
|
||||
ios << "4 ";
|
||||
if(FreeImage_FIFSupportsExportBPP(fif, 8))
|
||||
ios << "8 ";
|
||||
if(FreeImage_FIFSupportsExportBPP(fif, 16))
|
||||
ios << "16 ";
|
||||
if(FreeImage_FIFSupportsExportBPP(fif, 24))
|
||||
ios << "24 ";
|
||||
if(FreeImage_FIFSupportsExportBPP(fif, 32))
|
||||
ios << "32 ";
|
||||
if(FreeImage_FIFSupportsICCProfiles(fif)) {
|
||||
ios << ";" << icc;
|
||||
} else {
|
||||
ios << "; ";
|
||||
}
|
||||
ios << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_Initialise();
|
||||
#endif // FREEIMAGE_LIB
|
||||
|
||||
// initialize FreeImage error handler
|
||||
|
||||
FreeImage_SetOutputMessage(MyMessageFunc);
|
||||
|
||||
// print version & copyright infos
|
||||
|
||||
cout << "FreeImage " << FreeImage_GetVersion() << "\n";
|
||||
cout << FreeImage_GetCopyrightMessage() << "\n\n";
|
||||
|
||||
// Print input formats (including external plugins) known by the library
|
||||
fstream importFile("fif_import.csv", ios::out);
|
||||
PrintImportFormats(importFile);
|
||||
importFile.close();
|
||||
|
||||
// Print output formats (including plugins) known by the library
|
||||
// for each export format, supported bitdepths are given
|
||||
fstream exportFile("fif_export.csv", ios::out);
|
||||
PrintExportFormats(exportFile);
|
||||
exportFile.close();
|
||||
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_DeInitialise();
|
||||
#endif // FREEIMAGE_LIB
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
/*--------------------------------------------------------------------------*\
|
||||
|| fiio_mem.cpp by Ryan Rubley <ryan@lostreality.org> ||
|
||||
|| ||
|
||||
|| (v1.02) 4-28-2004 ||
|
||||
|| FreeImageIO to memory ||
|
||||
|| ||
|
||||
\*--------------------------------------------------------------------------*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "fiio_mem.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
FIBITMAP *
|
||||
FreeImage_LoadFromMem(FREE_IMAGE_FORMAT fif, fiio_mem_handle *handle, int flags) {
|
||||
FreeImageIO io;
|
||||
SetMemIO(&io);
|
||||
|
||||
if (handle && handle->data) {
|
||||
handle->curpos = 0;
|
||||
return FreeImage_LoadFromHandle(fif, &io, (fi_handle)handle, flags);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL
|
||||
FreeImage_SaveToMem(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, fiio_mem_handle *handle, int flags) {
|
||||
FreeImageIO io;
|
||||
SetMemIO(&io);
|
||||
|
||||
if (handle) {
|
||||
handle->filelen = 0;
|
||||
handle->curpos = 0;
|
||||
return FreeImage_SaveToHandle(fif, dib, &io, (fi_handle)handle, flags);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
void
|
||||
SetMemIO(FreeImageIO *io) {
|
||||
io->read_proc = fiio_mem_ReadProc;
|
||||
io->seek_proc = fiio_mem_SeekProc;
|
||||
io->tell_proc = fiio_mem_TellProc;
|
||||
io->write_proc = fiio_mem_WriteProc;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
#define FIIOMEM(member) (((fiio_mem_handle *)handle)->member)
|
||||
|
||||
unsigned
|
||||
fiio_mem_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
|
||||
unsigned x;
|
||||
for( x=0; x<count; x++ ) {
|
||||
//if there isnt size bytes left to read, set pos to eof and return a short count
|
||||
if( FIIOMEM(filelen)-FIIOMEM(curpos) < (long)size ) {
|
||||
FIIOMEM(curpos) = FIIOMEM(filelen);
|
||||
break;
|
||||
}
|
||||
//copy size bytes count times
|
||||
memcpy( buffer, (char *)FIIOMEM(data) + FIIOMEM(curpos), size );
|
||||
FIIOMEM(curpos) += size;
|
||||
buffer = (char *)buffer + size;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
unsigned
|
||||
fiio_mem_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
|
||||
void *newdata;
|
||||
long newdatalen;
|
||||
//double the data block size if we need to
|
||||
while( FIIOMEM(curpos)+(long)(size*count) >= FIIOMEM(datalen) ) {
|
||||
//if we are at or above 1G, we cant double without going negative
|
||||
if( FIIOMEM(datalen) & 0x40000000 ) {
|
||||
//max 2G
|
||||
if( FIIOMEM(datalen) == 0x7FFFFFFF ) {
|
||||
return 0;
|
||||
}
|
||||
newdatalen = 0x7FFFFFFF;
|
||||
} else if( FIIOMEM(datalen) == 0 ) {
|
||||
//default to 4K if nothing yet
|
||||
newdatalen = 4096;
|
||||
} else {
|
||||
//double size
|
||||
newdatalen = FIIOMEM(datalen) << 1;
|
||||
}
|
||||
newdata = realloc( FIIOMEM(data), newdatalen );
|
||||
if( !newdata ) {
|
||||
return 0;
|
||||
}
|
||||
FIIOMEM(data) = newdata;
|
||||
FIIOMEM(datalen) = newdatalen;
|
||||
}
|
||||
memcpy( (char *)FIIOMEM(data) + FIIOMEM(curpos), buffer, size*count );
|
||||
FIIOMEM(curpos) += size*count;
|
||||
if( FIIOMEM(curpos) > FIIOMEM(filelen) ) {
|
||||
FIIOMEM(filelen) = FIIOMEM(curpos);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int
|
||||
fiio_mem_SeekProc(fi_handle handle, long offset, int origin) {
|
||||
switch(origin) { //0 to filelen-1 are 'inside' the file
|
||||
default:
|
||||
case SEEK_SET: //can fseek() to 0-7FFFFFFF always
|
||||
if( offset >= 0 ) {
|
||||
FIIOMEM(curpos) = offset;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEEK_CUR:
|
||||
if( FIIOMEM(curpos)+offset >= 0 ) {
|
||||
FIIOMEM(curpos) += offset;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEEK_END:
|
||||
if( FIIOMEM(filelen)+offset >= 0 ) {
|
||||
FIIOMEM(curpos) = FIIOMEM(filelen)+offset;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
long
|
||||
fiio_mem_TellProc(fi_handle handle) {
|
||||
return FIIOMEM(curpos);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,74 @@
|
||||
/*--------------------------------------------------------------------------*\
|
||||
|| fiio_mem.h by Ryan Rubley <ryan@lostreality.org> ||
|
||||
|| ||
|
||||
|| (v1.02) 4-28-2004 ||
|
||||
|| FreeImageIO to memory ||
|
||||
|| ||
|
||||
\*--------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _FIIO_MEM_H_
|
||||
#define _FIIO_MEM_H_
|
||||
|
||||
#include "freeimage.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct fiio_mem_handle_s {
|
||||
long filelen,datalen,curpos;
|
||||
void *data;
|
||||
} fiio_mem_handle;
|
||||
|
||||
/* it is up to the user to create a fiio_mem_handle and init datalen and data
|
||||
* filelen will be pre-set to 0 by SaveToMem
|
||||
* curpos will be pre-set to 0 by SaveToMem and LoadFromMem
|
||||
* IMPORTANT: data should be set to NULL and datalen to 0,
|
||||
* unless the user wants to manually malloc a larger buffer
|
||||
*/
|
||||
FIBITMAP *FreeImage_LoadFromMem(FREE_IMAGE_FORMAT fif, fiio_mem_handle *handle, int flags);
|
||||
BOOL FreeImage_SaveToMem(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, fiio_mem_handle *handle, int flags);
|
||||
|
||||
void SetMemIO(FreeImageIO *io);
|
||||
unsigned fiio_mem_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle);
|
||||
unsigned fiio_mem_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle);
|
||||
int fiio_mem_SeekProc(fi_handle handle, long offset, int origin);
|
||||
long fiio_mem_TellProc(fi_handle handle);
|
||||
|
||||
/*** Example Usage ***
|
||||
|
||||
//variables
|
||||
FIBITMAP *bitmap, *bitmap2;
|
||||
fiio_mem_handle fmh;
|
||||
|
||||
//important initialization
|
||||
fmh.data = NULL;
|
||||
fmh.datalen = 0;
|
||||
|
||||
//load a regular file
|
||||
bitmap = FreeImage_Load(FIF_PNG, "sample.png");
|
||||
|
||||
//save the file to memory
|
||||
FreeImage_SaveToMem(FIF_PNG, bitmap, &fmh, 0);
|
||||
|
||||
//at this point, fmh.data contains the entire PNG data in memory
|
||||
//fmh.datalen is the amount of space malloc'd for the image in memory,
|
||||
//but only fmh.filelen amount of that space is actually used.
|
||||
|
||||
//its easy load an image from memory as well
|
||||
bitmap2 = FreeImage_LoadFromMem(FIF_PNG, &fmh, 0);
|
||||
//you could also have image data in memory via some other method, and just set
|
||||
//fmh.data to point to it, and set both fmh.datalen and fmh.filelen to the
|
||||
//size of that data, then FreeImage_LoadFromMem could load the image from that
|
||||
//memory
|
||||
|
||||
//make sure to free the data since SaveToMem will cause it to be malloc'd
|
||||
free(fmh.data);
|
||||
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,145 @@
|
||||
// ==========================================================
|
||||
// Load From Handle Example
|
||||
//
|
||||
// Design and implementation by
|
||||
// - Hervé Drolon
|
||||
//
|
||||
// This file is part of FreeImage 3
|
||||
//
|
||||
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
|
||||
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
|
||||
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
|
||||
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
|
||||
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
|
||||
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
|
||||
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
|
||||
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
|
||||
// THIS DISCLAIMER.
|
||||
//
|
||||
// Use at own risk!
|
||||
// ==========================================================
|
||||
|
||||
// This example shows how to load a bitmap from a
|
||||
// user allocated FILE pointer.
|
||||
//
|
||||
// Functions used in this sample :
|
||||
// FreeImage_GetFormatFromFIF, FreeImage_GetFileTypeFromHandle, FreeImage_LoadFromHandle,
|
||||
// FreeImage_GetFIFFromFilename, FreeImage_Save, FreeImage_Unload
|
||||
// FreeImage_GetVersion, FreeImage_GetCopyrightMessage, FreeImage_SetOutputMessage
|
||||
//
|
||||
// ==========================================================
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "FreeImage.h"
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
FreeImage error handler
|
||||
@param fif Format / Plugin responsible for the error
|
||||
@param message Error message
|
||||
*/
|
||||
void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) {
|
||||
printf("\n*** ");
|
||||
if(fif != FIF_UNKNOWN) {
|
||||
printf("%s Format\n", FreeImage_GetFormatFromFIF(fif));
|
||||
}
|
||||
printf(message);
|
||||
printf(" ***\n");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
unsigned DLL_CALLCONV
|
||||
myReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
|
||||
return fread(buffer, size, count, (FILE *)handle);
|
||||
}
|
||||
|
||||
unsigned DLL_CALLCONV
|
||||
myWriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
|
||||
return fwrite(buffer, size, count, (FILE *)handle);
|
||||
}
|
||||
|
||||
int DLL_CALLCONV
|
||||
mySeekProc(fi_handle handle, long offset, int origin) {
|
||||
return fseek((FILE *)handle, offset, origin);
|
||||
}
|
||||
|
||||
long DLL_CALLCONV
|
||||
myTellProc(fi_handle handle) {
|
||||
return ftell((FILE *)handle);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_Initialise();
|
||||
#endif // FREEIMAGE_LIB
|
||||
|
||||
// initialize your own FreeImage error handler
|
||||
|
||||
FreeImage_SetOutputMessage(FreeImageErrorHandler);
|
||||
|
||||
// print version & copyright infos
|
||||
|
||||
printf(FreeImage_GetVersion());
|
||||
printf("\n");
|
||||
printf(FreeImage_GetCopyrightMessage());
|
||||
printf("\n");
|
||||
|
||||
|
||||
if(argc != 2) {
|
||||
printf("Usage : LoadFromHandle <input file name>\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// initialize your own IO functions
|
||||
|
||||
FreeImageIO io;
|
||||
|
||||
io.read_proc = myReadProc;
|
||||
io.write_proc = myWriteProc;
|
||||
io.seek_proc = mySeekProc;
|
||||
io.tell_proc = myTellProc;
|
||||
|
||||
FILE *file = fopen(argv[1], "rb");
|
||||
|
||||
if (file != NULL) {
|
||||
// find the buffer format
|
||||
FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromHandle(&io, (fi_handle)file, 0);
|
||||
|
||||
if(fif != FIF_UNKNOWN) {
|
||||
// load from the file handle
|
||||
FIBITMAP *dib = FreeImage_LoadFromHandle(fif, &io, (fi_handle)file, 0);
|
||||
|
||||
// save the bitmap as a PNG ...
|
||||
const char *output_filename = "test.png";
|
||||
|
||||
// first, check the output format from the file name or file extension
|
||||
FREE_IMAGE_FORMAT out_fif = FreeImage_GetFIFFromFilename(output_filename);
|
||||
|
||||
if(out_fif != FIF_UNKNOWN) {
|
||||
// then save the file
|
||||
FreeImage_Save(out_fif, dib, output_filename, 0);
|
||||
}
|
||||
|
||||
// free the loaded FIBITMAP
|
||||
FreeImage_Unload(dib);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_DeInitialise();
|
||||
#endif // FREEIMAGE_LIB
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
// ==========================================================
|
||||
// Classified FreeImageIO handler
|
||||
//
|
||||
// Design and implementation by
|
||||
// - schickb (schickb@hotmail.com)
|
||||
//
|
||||
// This file is part of FreeImage 3
|
||||
//
|
||||
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
|
||||
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
|
||||
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
|
||||
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
|
||||
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
|
||||
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
|
||||
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
|
||||
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
|
||||
// THIS DISCLAIMER.
|
||||
//
|
||||
// Use at your own risk!
|
||||
// ==========================================================
|
||||
|
||||
class MemIO : public FreeImageIO {
|
||||
public :
|
||||
MemIO( BYTE *data ) : _start(data), _cp(data) {
|
||||
read_proc = _ReadProc;
|
||||
write_proc = _WriteProc;
|
||||
tell_proc = _TellProc;
|
||||
seek_proc = _SeekProc;
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
_cp = _start;
|
||||
}
|
||||
|
||||
static unsigned _ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle);
|
||||
static unsigned _WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle);
|
||||
static int _SeekProc(fi_handle handle, long offset, int origin);
|
||||
static long _TellProc(fi_handle handle);
|
||||
|
||||
private:
|
||||
BYTE * const _start;
|
||||
BYTE *_cp;
|
||||
};
|
||||
|
||||
|
||||
unsigned
|
||||
MemIO::_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
|
||||
MemIO *memIO = (MemIO*)handle;
|
||||
|
||||
BYTE *tmp = (BYTE *)buffer;
|
||||
|
||||
for (unsigned c = 0; c < count; c++) {
|
||||
memcpy(tmp, memIO->_cp, size);
|
||||
|
||||
memIO->_cp = memIO->_cp + size;
|
||||
|
||||
tmp += size;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
unsigned
|
||||
MemIO::_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
|
||||
ASSERT( false );
|
||||
return size;
|
||||
}
|
||||
|
||||
int
|
||||
MemIO::_SeekProc(fi_handle handle, long offset, int origin) {
|
||||
ASSERT(origin != SEEK_END);
|
||||
|
||||
MemIO *memIO = (MemIO*)handle;
|
||||
|
||||
if (origin == SEEK_SET)
|
||||
memIO->_cp = memIO->_start + offset;
|
||||
else
|
||||
memIO->_cp = memIO->_cp + offset;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
long
|
||||
MemIO::_TellProc(fi_handle handle) {
|
||||
MemIO *memIO = (MemIO*)handle;
|
||||
|
||||
return memIO->_cp - memIO->_start;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// PSEUDOCODE... HELPS TO UNDERSTAND HOW THE MEMIO CLASS WORKS
|
||||
// ----------------------------------------------------------
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
BYTE *data = loadimagesomehow();
|
||||
|
||||
MemIO memIO(data);
|
||||
|
||||
FIBITMAP *fbmp = FreeImage_LoadFromHandle( fif, &memIO, (fi_handle)&memIO );
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
// ==========================================================
|
||||
// Load From Memory Example
|
||||
//
|
||||
// Design and implementation by Floris van den Berg
|
||||
//
|
||||
// This file is part of FreeImage 3
|
||||
//
|
||||
// Use at own risk!
|
||||
// ==========================================================
|
||||
//
|
||||
// This example shows how to load a bitmap from memory
|
||||
// rather than from a file. To do this we make use of the
|
||||
// FreeImage_LoadFromHandle functions where we override
|
||||
// the i/o functions to simulate FILE* access in memory.
|
||||
//
|
||||
// For seeking purposes the fi_handle passed to the i/o
|
||||
// functions contain the start of the data block where the
|
||||
// bitmap is stored.
|
||||
//
|
||||
// ==========================================================
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "FreeImage.h"
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
fi_handle g_load_address;
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
inline unsigned _stdcall
|
||||
_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
|
||||
BYTE *tmp = (BYTE *)buffer;
|
||||
|
||||
for (unsigned c = 0; c < count; c++) {
|
||||
memcpy(tmp, g_load_address, size);
|
||||
|
||||
g_load_address = (BYTE *)g_load_address + size;
|
||||
|
||||
tmp += size;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
inline unsigned _stdcall
|
||||
_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
|
||||
// there's not much use for saving the bitmap into memory now, is there?
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
inline int _stdcall
|
||||
_SeekProc(fi_handle handle, long offset, int origin) {
|
||||
assert(origin != SEEK_END);
|
||||
|
||||
if (origin == SEEK_SET) {
|
||||
g_load_address = (BYTE *)handle + offset;
|
||||
} else {
|
||||
g_load_address = (BYTE *)g_load_address + offset;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline long _stdcall
|
||||
_TellProc(fi_handle handle) {
|
||||
assert((int)handle > (int)g_load_address);
|
||||
|
||||
return ((int)g_load_address - (int)handle);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
FreeImageIO io;
|
||||
|
||||
io.read_proc = _ReadProc;
|
||||
io.write_proc = _WriteProc;
|
||||
io.tell_proc = _TellProc;
|
||||
io.seek_proc = _SeekProc;
|
||||
|
||||
// allocate some memory for the bitmap
|
||||
|
||||
BYTE *test = new BYTE[159744];
|
||||
|
||||
if (test != NULL) {
|
||||
// load the bitmap into memory. ofcourse you can do this any way you want
|
||||
|
||||
FILE *file = fopen("e:\\projects\\images\\money-256.tif", "rb");
|
||||
fread(test, 159744, 1, file);
|
||||
fclose(file);
|
||||
|
||||
// we store the load address of the bitmap for internal reasons
|
||||
|
||||
g_load_address = test;
|
||||
|
||||
// convert the bitmap
|
||||
|
||||
FIBITMAP *dib = FreeImage_LoadFromHandle(FIF_TIFF, &io, (fi_handle)test);
|
||||
|
||||
// don't forget to free the dib !
|
||||
FreeImage_Unload(dib);
|
||||
|
||||
delete [] test;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,317 @@
|
||||
// ==========================================================
|
||||
// Simple metadata reader
|
||||
//
|
||||
// Design and implementation by
|
||||
// - Hervé Drolon
|
||||
//
|
||||
// This file is part of FreeImage 3
|
||||
//
|
||||
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
|
||||
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
|
||||
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
|
||||
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
|
||||
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
|
||||
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
|
||||
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
|
||||
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
|
||||
// THIS DISCLAIMER.
|
||||
//
|
||||
// Use at own risk!
|
||||
// ==========================================================
|
||||
|
||||
//
|
||||
// This example shows how to easily parse all metadata
|
||||
// contained in a JPEG, TIFF or PNG image.
|
||||
// Comments, Exif and IPTC/NAA metadata tags are written to a HTML file
|
||||
// for later reading, and Adobe XMP XML packets are written
|
||||
// in a file whose extension is '.xmp'. This file can be later
|
||||
// processed using a XML parser.
|
||||
//
|
||||
// Metadata functions showed in this sample :
|
||||
// FreeImage_GetMetadataCount, FreeImage_FindFirstMetadata, FreeImage_FindNextMetadata,
|
||||
// FreeImage_FindCloseMetadata, FreeImage_TagToString, FreeImage_GetMetadata
|
||||
//
|
||||
// ==========================================================
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "FreeImage.h"
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/** Generic image loader
|
||||
@param lpszPathName Pointer to the full file name
|
||||
@param flag Optional load flag constant
|
||||
@return Returns the loaded dib if successful, returns NULL otherwise
|
||||
*/
|
||||
FIBITMAP* GenericLoader(const char* lpszPathName, int flag) {
|
||||
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
|
||||
|
||||
// check the file signature and deduce its format
|
||||
// (the second argument is currently not used by FreeImage)
|
||||
fif = FreeImage_GetFileType(lpszPathName, 0);
|
||||
if(fif == FIF_UNKNOWN) {
|
||||
// no signature ?
|
||||
// try to guess the file format from the file extension
|
||||
fif = FreeImage_GetFIFFromFilename(lpszPathName);
|
||||
}
|
||||
// check that the plugin has reading capabilities ...
|
||||
if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {
|
||||
// ok, let's load the file
|
||||
FIBITMAP *dib = FreeImage_Load(fif, lpszPathName, flag);
|
||||
// unless a bad file format, we are done !
|
||||
return dib;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Generic image writer
|
||||
@param dib Pointer to the dib to be saved
|
||||
@param lpszPathName Pointer to the full file name
|
||||
@param flag Optional save flag constant
|
||||
@return Returns true if successful, returns false otherwise
|
||||
*/
|
||||
bool GenericWriter(FIBITMAP* dib, const char* lpszPathName, int flag) {
|
||||
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
|
||||
BOOL bSuccess = FALSE;
|
||||
|
||||
if(dib) {
|
||||
// try to guess the file format from the file extension
|
||||
fif = FreeImage_GetFIFFromFilename(lpszPathName);
|
||||
if(fif != FIF_UNKNOWN ) {
|
||||
// check that the plugin has sufficient writing and export capabilities ...
|
||||
WORD bpp = FreeImage_GetBPP(dib);
|
||||
if(FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp)) {
|
||||
// ok, we can save the file
|
||||
bSuccess = FreeImage_Save(fif, dib, lpszPathName, flag);
|
||||
// unless an abnormal bug, we are done !
|
||||
}
|
||||
}
|
||||
}
|
||||
return (bSuccess == TRUE) ? true : false;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
FreeImage error handler
|
||||
@param fif Format / Plugin responsible for the error
|
||||
@param message Error message
|
||||
*/
|
||||
void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) {
|
||||
cout << "\n*** ";
|
||||
if(fif != FIF_UNKNOWN) {
|
||||
cout << FreeImage_GetFormatFromFIF(fif) << " Format\n";
|
||||
}
|
||||
cout << message;
|
||||
cout << " ***\n";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Print a basic HTML header
|
||||
*/
|
||||
void PrintHTMLHeader(iostream& ios) {
|
||||
ios << "<HTML>\n<BODY>\n<CENTER>\n";
|
||||
ios << "<FONT FACE = \"Arial\">\n";
|
||||
}
|
||||
|
||||
/**
|
||||
Print a HTML footer
|
||||
*/
|
||||
void PrintHTMLFooter(iostream& ios) {
|
||||
ios << "</CENTER>\n</FONT>\n</BODY>\n</HTML>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
Print a table header
|
||||
*/
|
||||
void PrintTableHeader(iostream& ios, const char *title) {
|
||||
ios << "<TABLE BORDER=\"1\">\n";
|
||||
ios << "<TR><TD ALIGN=CENTER COLSPAN=\"3\" BGCOLOR=\"#CCCCCC\"><B><font face=\"Arial\">" << title << "</font></B></TD></TR>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
Print a table section
|
||||
*/
|
||||
void PrintTableSection(iostream& ios, const char *title) {
|
||||
ios << "<TR><TD ALIGN=CENTER COLSPAN=\"3\" BGCOLOR=\"#FFFFCC\"><B><font face=\"Arial\">" << title << "</font></B></TD></TR>\n";
|
||||
ios << "<TR><TD><B>Tag name</B></TD><TD><B>Tag value</B></TD><TD><B>Description</B></TD></TR>";
|
||||
}
|
||||
|
||||
/**
|
||||
Print a table footer
|
||||
*/
|
||||
void PrintTableFooter(iostream& ios) {
|
||||
ios << "</TABLE>\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Print the metadata tags to a HTML file
|
||||
*/
|
||||
void PrintMetadata(iostream& ios, const char *sectionTitle, FIBITMAP *dib, FREE_IMAGE_MDMODEL model) {
|
||||
FITAG *tag = NULL;
|
||||
FIMETADATA *mdhandle = NULL;
|
||||
|
||||
mdhandle = FreeImage_FindFirstMetadata(model, dib, &tag);
|
||||
|
||||
if(mdhandle) {
|
||||
// Print a table section
|
||||
PrintTableSection(ios, sectionTitle);
|
||||
|
||||
do {
|
||||
// convert the tag value to a string
|
||||
const char *value = FreeImage_TagToString(model, tag);
|
||||
|
||||
// print the tag
|
||||
// note that most tags do not have a description,
|
||||
// especially when the metadata specifications are not available
|
||||
if(FreeImage_GetTagDescription(tag)) {
|
||||
ios << "<TR><TD>" << FreeImage_GetTagKey(tag) << "</TD><TD>" << value << "</TD><TD>" << FreeImage_GetTagDescription(tag) << "</TD></TR>\n";
|
||||
} else {
|
||||
ios << "<TR><TD>" << FreeImage_GetTagKey(tag) << "</TD><TD>" << value << "</TD><TD>" << " " << "</TD></TR>\n";
|
||||
}
|
||||
|
||||
} while(FreeImage_FindNextMetadata(mdhandle, &tag));
|
||||
}
|
||||
|
||||
FreeImage_FindCloseMetadata(mdhandle);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
unsigned count;
|
||||
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_Initialise();
|
||||
#endif // FREEIMAGE_LIB
|
||||
|
||||
// initialize your own FreeImage error handler
|
||||
|
||||
FreeImage_SetOutputMessage(FreeImageErrorHandler);
|
||||
|
||||
// print version & copyright infos
|
||||
|
||||
cout << "FreeImage " << FreeImage_GetVersion() << "\n";
|
||||
cout << FreeImage_GetCopyrightMessage() << "\n\n";
|
||||
|
||||
if(argc != 2) {
|
||||
cout << "Usage : ShowMetadata <input file name>\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Load the bitmap
|
||||
|
||||
FIBITMAP *dib = GenericLoader(argv[1], 0);
|
||||
if(!dib)
|
||||
return 0;
|
||||
|
||||
// Create a HTML file
|
||||
std::string html_file(strtok(argv[1], ".") + std::string(".html"));
|
||||
|
||||
fstream metadataFile(html_file.c_str(), ios::out);
|
||||
|
||||
// Print the header
|
||||
|
||||
PrintHTMLHeader(metadataFile);
|
||||
PrintTableHeader(metadataFile, argv[1]);
|
||||
|
||||
// Parse and print metadata
|
||||
|
||||
if(count = FreeImage_GetMetadataCount(FIMD_COMMENTS, dib)) {
|
||||
cout << "\nFIMD_COMMENTS (" << count << " data)\n-----------------------------------------\n";
|
||||
|
||||
PrintMetadata(metadataFile, "Comments", dib, FIMD_COMMENTS);
|
||||
}
|
||||
if(count = FreeImage_GetMetadataCount(FIMD_EXIF_MAIN, dib)) {
|
||||
cout << "\nFIMD_EXIF_MAIN (" << count << " data)\n-----------------------------------------\n";
|
||||
|
||||
PrintMetadata(metadataFile, "Exif - main info", dib, FIMD_EXIF_MAIN);
|
||||
}
|
||||
if(count = FreeImage_GetMetadataCount(FIMD_EXIF_EXIF, dib)) {
|
||||
cout << "\nFIMD_EXIF_EXIF (" << count << " data)\n-----------------------------------------\n";
|
||||
|
||||
PrintMetadata(metadataFile, "Exif - advanced info", dib, FIMD_EXIF_EXIF);
|
||||
}
|
||||
if(count = FreeImage_GetMetadataCount(FIMD_EXIF_GPS, dib)) {
|
||||
cout << "\nFIMD_EXIF_GPS (" << count << " data)\n-----------------------------------------\n";
|
||||
|
||||
PrintMetadata(metadataFile, "Exif GPS", dib, FIMD_EXIF_GPS);
|
||||
}
|
||||
if(count = FreeImage_GetMetadataCount(FIMD_EXIF_INTEROP, dib)) {
|
||||
cout << "\nFIMD_EXIF_INTEROP (" << count << " data)\n-----------------------------------------\n";
|
||||
|
||||
PrintMetadata(metadataFile, "Exif interoperability", dib, FIMD_EXIF_INTEROP);
|
||||
}
|
||||
if(count = FreeImage_GetMetadataCount(FIMD_EXIF_MAKERNOTE, dib)) {
|
||||
cout << "\nFIMD_EXIF_MAKERNOTE (" << count << " data)\n-----------------------------------------\n";
|
||||
|
||||
// Get the camera model
|
||||
FITAG *tagMake = NULL;
|
||||
FreeImage_GetMetadata(FIMD_EXIF_MAIN, dib, "Make", &tagMake);
|
||||
|
||||
std::string buffer((char*)FreeImage_GetTagValue(tagMake));
|
||||
buffer += " Makernote";
|
||||
|
||||
PrintMetadata(metadataFile, buffer.c_str(), dib, FIMD_EXIF_MAKERNOTE);
|
||||
}
|
||||
if(count = FreeImage_GetMetadataCount(FIMD_IPTC, dib)) {
|
||||
cout << "\nFIMD_IPTC (" << count << " data)\n-----------------------------------------\n";
|
||||
|
||||
PrintMetadata(metadataFile, "IPTC/NAA", dib, FIMD_IPTC);
|
||||
}
|
||||
if(count = FreeImage_GetMetadataCount(FIMD_GEOTIFF, dib)) {
|
||||
cout << "\nFIMD_GEOTIFF (" << count << " data)\n-----------------------------------------\n";
|
||||
|
||||
PrintMetadata(metadataFile, "GEOTIFF", dib, FIMD_GEOTIFF);
|
||||
}
|
||||
|
||||
// Print the footer
|
||||
|
||||
PrintTableFooter(metadataFile);
|
||||
PrintHTMLFooter(metadataFile);
|
||||
|
||||
// close the HTML file
|
||||
|
||||
metadataFile.close();
|
||||
|
||||
// print XMP data
|
||||
|
||||
if(count = FreeImage_GetMetadataCount(FIMD_XMP, dib)) {
|
||||
cout << "\nFIMD_XMP (" << count << " packet)\n-----------------------------------------\n";
|
||||
|
||||
std::string xmp_file(strtok(argv[1], ".") + std::string(".xmp"));
|
||||
metadataFile.open(xmp_file.c_str(), ios::out);
|
||||
|
||||
FITAG *tag = NULL;
|
||||
FreeImage_GetMetadata(FIMD_XMP, dib, "XMLPacket", &tag);
|
||||
if(tag) {
|
||||
metadataFile << (char*)FreeImage_GetTagValue(tag);
|
||||
}
|
||||
|
||||
metadataFile.close();
|
||||
}
|
||||
|
||||
|
||||
// Unload the bitmap
|
||||
|
||||
FreeImage_Unload(dib);
|
||||
|
||||
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_DeInitialise();
|
||||
#endif // FREEIMAGE_LIB
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
CC = gcc
|
||||
CPP = g++
|
||||
COMPILERFLAGS = -O3
|
||||
INCLUDE = -I../../Dist
|
||||
VGALIBRARIES = -lfreeimage -lvga
|
||||
VGAINCLUDE = -I/usr/include/asm
|
||||
GTKLIBRARIES = -lfreeimage `pkg-config --libs gtk+-2.0`
|
||||
GTKINCLUDE = `pkg-config --cflags gtk+-2.0`
|
||||
CFLAGS = $(COMPILERFLAGS) $(INCLUDE)
|
||||
|
||||
all: default
|
||||
|
||||
default: linux-svgalib linux-gtk
|
||||
|
||||
linux-svgalib: linux-svgalib.c
|
||||
$(CC) $(CFLAGS) $< -o $@ $(VGALIBRARIES) $(VGAINCLUDE)
|
||||
strip $@
|
||||
|
||||
linux-gtk: linux-gtk.c
|
||||
$(CC) $(CFLAGS) $< -o $@ $(GTKLIBRARIES) $(GTKINCLUDE)
|
||||
strip $@
|
||||
|
||||
clean:
|
||||
rm -f core linux-svgalib linux-gtk
|
@ -0,0 +1,100 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <FreeImage.h>
|
||||
#include <string.h>
|
||||
|
||||
void destroy(GtkWidget * widget, gpointer data) {
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window, *imagebox;
|
||||
GdkVisual *visual;
|
||||
GdkImage *image;
|
||||
FIBITMAP *dib;
|
||||
int y;
|
||||
|
||||
// initialize the FreeImage library
|
||||
FreeImage_Initialise(TRUE);
|
||||
|
||||
dib = FreeImage_Load(FIF_PNG, "freeimage.png", PNG_DEFAULT);
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(window), "destroy",
|
||||
GTK_SIGNAL_FUNC(destroy), NULL);
|
||||
|
||||
visual = gdk_visual_get_system();
|
||||
|
||||
image = gdk_image_new(GDK_IMAGE_NORMAL,visual,
|
||||
FreeImage_GetWidth(dib),FreeImage_GetHeight(dib));
|
||||
|
||||
g_print("picture: %d bpp\n"
|
||||
"system: %d bpp byteorder: %d\n"
|
||||
" redbits: %d greenbits: %d bluebits: %d\n"
|
||||
"image: %d bpp %d bytes/pixel\n",
|
||||
FreeImage_GetBPP(dib),
|
||||
visual->depth,visual->byte_order,
|
||||
visual->red_prec,visual->green_prec,visual->blue_prec,
|
||||
image->depth,image->bpp );
|
||||
|
||||
if (FreeImage_GetBPP(dib) != (image->bpp << 3)) {
|
||||
FIBITMAP *ptr;
|
||||
|
||||
switch (image->bpp) {
|
||||
case 1:
|
||||
ptr = FreeImage_ConvertTo8Bits(dib);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (image->depth == 15) {
|
||||
ptr = FreeImage_ConvertTo16Bits555(dib);
|
||||
} else {
|
||||
ptr = FreeImage_ConvertTo16Bits565(dib);
|
||||
}
|
||||
|
||||
break;
|
||||
case 3:
|
||||
ptr = FreeImage_ConvertTo24Bits(dib);
|
||||
break;
|
||||
|
||||
default:
|
||||
case 4:
|
||||
ptr = FreeImage_ConvertTo32Bits(dib);
|
||||
break;
|
||||
}
|
||||
|
||||
FreeImage_Unload(dib);
|
||||
dib = ptr;
|
||||
}
|
||||
|
||||
//makes it upside down :(
|
||||
// memcpy(image->mem, FreeImage_GetBits(dib), image->bpl * image->height);
|
||||
|
||||
BYTE *ptr = FreeImage_GetBits(dib);
|
||||
|
||||
for (y = 0; y < image->height; y++) {
|
||||
memcpy(image->mem + (y * image->bpl),
|
||||
ptr + ((image->height - y - 1) * image->bpl),
|
||||
image->bpl);
|
||||
}
|
||||
|
||||
FreeImage_Unload(dib);
|
||||
|
||||
imagebox = gtk_image_new_from_image(image, NULL);
|
||||
gtk_container_add(GTK_CONTAINER(window), imagebox);
|
||||
|
||||
gtk_widget_show(imagebox);
|
||||
gtk_widget_show(window);
|
||||
|
||||
gtk_main();
|
||||
|
||||
// release the FreeImage library
|
||||
FreeImage_DeInitialise();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,96 @@
|
||||
#include <vga.h>
|
||||
#include "FreeImage.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
FIBITMAP *dib,*ptr;
|
||||
vga_modeinfo *inf;
|
||||
int length,height,bpp,y;
|
||||
|
||||
// initialize the FreeImage library
|
||||
FreeImage_Initialise();
|
||||
|
||||
dib = FreeImage_Load(FIF_PNG, "freeimage.png", PNG_DEFAULT);
|
||||
|
||||
vga_init();
|
||||
vga_setmode(vga_getdefaultmode());
|
||||
|
||||
inf = vga_getmodeinfo(vga_getcurrentmode());
|
||||
|
||||
switch(inf->colors) {
|
||||
default:
|
||||
printf("Must be at least 256 color mode!\n");
|
||||
return;
|
||||
|
||||
case 1 << 8:
|
||||
bpp = 8;
|
||||
break;
|
||||
|
||||
case 1 << 15:
|
||||
bpp = 15;
|
||||
break;
|
||||
|
||||
case 1 << 16:
|
||||
bpp = 16;
|
||||
break;
|
||||
|
||||
case 1 << 24:
|
||||
if( inf->bytesperpixel == 3 ) {
|
||||
bpp = 24;
|
||||
} else {
|
||||
bpp = 32;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(FreeImage_GetBPP(dib) != bpp) {
|
||||
switch(bpp) {
|
||||
case 8:
|
||||
ptr = FreeImage_ConvertTo8Bits(dib);
|
||||
break;
|
||||
|
||||
case 15:
|
||||
ptr = FreeImage_ConvertTo16Bits555(dib);
|
||||
break;
|
||||
|
||||
case 16:
|
||||
ptr = FreeImage_ConvertTo16Bits565(dib);
|
||||
break;
|
||||
|
||||
case 24:
|
||||
ptr = FreeImage_ConvertTo24Bits(dib);
|
||||
break;
|
||||
|
||||
default:
|
||||
case 32:
|
||||
ptr = FreeImage_ConvertTo32Bits(dib);
|
||||
break;
|
||||
}
|
||||
|
||||
FreeImage_Unload(dib);
|
||||
dib = ptr;
|
||||
}
|
||||
|
||||
length = FreeImage_GetWidth(dib);
|
||||
if( inf->width < length ) {
|
||||
length = inf->width;
|
||||
}
|
||||
height = FreeImage_GetHeight(dib);
|
||||
if( inf->height < height ) {
|
||||
height = inf->height;
|
||||
}
|
||||
|
||||
for(y = 0; y < height; y++) {
|
||||
vga_drawscansegment(FreeImage_GetScanLine(dib, y), 0, y, length);
|
||||
}
|
||||
|
||||
FreeImage_Unload(dib);
|
||||
|
||||
vga_getch();
|
||||
vga_setmode(TEXT);
|
||||
|
||||
// release the FreeImage library
|
||||
FreeImage_DeInitialise();
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
//**********************************************
|
||||
//Singleton Texture Manager class
|
||||
//Written by Ben English
|
||||
//benjamin.english@oit.edu
|
||||
//
|
||||
//For use with OpenGL and the FreeImage library
|
||||
//**********************************************
|
||||
|
||||
#include "TextureManager.h"
|
||||
|
||||
TextureManager* TextureManager::m_inst(0);
|
||||
|
||||
TextureManager* TextureManager::Inst()
|
||||
{
|
||||
if(!m_inst)
|
||||
m_inst = new TextureManager();
|
||||
|
||||
return m_inst;
|
||||
}
|
||||
|
||||
TextureManager::TextureManager()
|
||||
{
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_Initialise();
|
||||
#endif
|
||||
}
|
||||
|
||||
//these should never be called
|
||||
//TextureManager::TextureManager(const TextureManager& tm){}
|
||||
//TextureManager& TextureManager::operator=(const TextureManager& tm){}
|
||||
|
||||
TextureManager::~TextureManager()
|
||||
{
|
||||
// call this ONLY when linking with FreeImage as a static library
|
||||
#ifdef FREEIMAGE_LIB
|
||||
FreeImage_DeInitialise();
|
||||
#endif
|
||||
|
||||
UnloadAllTextures();
|
||||
m_inst = 0;
|
||||
}
|
||||
|
||||
bool TextureManager::LoadTexture(const char* filename, const unsigned int texID, GLenum image_format, GLint internal_format, GLint level, GLint border)
|
||||
{
|
||||
//image format
|
||||
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
|
||||
//pointer to the image, once loaded
|
||||
FIBITMAP *dib(0);
|
||||
//pointer to the image data
|
||||
BYTE* bits(0);
|
||||
//image width and height
|
||||
unsigned int width(0), height(0);
|
||||
//OpenGL's image ID to map to
|
||||
GLuint gl_texID;
|
||||
|
||||
//check the file signature and deduce its format
|
||||
fif = FreeImage_GetFileType(filename, 0);
|
||||
//if still unknown, try to guess the file format from the file extension
|
||||
if(fif == FIF_UNKNOWN)
|
||||
fif = FreeImage_GetFIFFromFilename(filename);
|
||||
//if still unkown, return failure
|
||||
if(fif == FIF_UNKNOWN)
|
||||
return false;
|
||||
|
||||
//check that the plugin has reading capabilities and load the file
|
||||
if(FreeImage_FIFSupportsReading(fif))
|
||||
dib = FreeImage_Load(fif, filename);
|
||||
//if the image failed to load, return failure
|
||||
if(!dib)
|
||||
return false;
|
||||
|
||||
//retrieve the image data
|
||||
bits = FreeImage_GetBits(dib);
|
||||
//get the image width and height
|
||||
width = FreeImage_GetWidth(dib);
|
||||
height = FreeImage_GetHeight(dib);
|
||||
//if this somehow one of these failed (they shouldn't), return failure
|
||||
if((bits == 0) || (width == 0) || (height == 0))
|
||||
return false;
|
||||
|
||||
//if this texture ID is in use, unload the current texture
|
||||
if(m_texID.find(texID) != m_texID.end())
|
||||
glDeleteTextures(1, &(m_texID[texID]));
|
||||
|
||||
//generate an OpenGL texture ID for this texture
|
||||
glGenTextures(1, &gl_texID);
|
||||
//store the texture ID mapping
|
||||
m_texID[texID] = gl_texID;
|
||||
//bind to the new texture ID
|
||||
glBindTexture(GL_TEXTURE_2D, gl_texID);
|
||||
//store the texture data for OpenGL use
|
||||
glTexImage2D(GL_TEXTURE_2D, level, internal_format, width, height,
|
||||
border, image_format, GL_UNSIGNED_BYTE, bits);
|
||||
|
||||
//Free FreeImage's copy of the data
|
||||
FreeImage_Unload(dib);
|
||||
|
||||
//return success
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TextureManager::UnloadTexture(const unsigned int texID)
|
||||
{
|
||||
bool result(true);
|
||||
//if this texture ID mapped, unload it's texture, and remove it from the map
|
||||
if(m_texID.find(texID) != m_texID.end())
|
||||
{
|
||||
glDeleteTextures(1, &(m_texID[texID]));
|
||||
m_texID.erase(texID);
|
||||
}
|
||||
//otherwise, unload failed
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TextureManager::BindTexture(const unsigned int texID)
|
||||
{
|
||||
bool result(true);
|
||||
//if this texture ID mapped, bind it's texture as current
|
||||
if(m_texID.find(texID) != m_texID.end())
|
||||
glBindTexture(GL_TEXTURE_2D, m_texID[texID]);
|
||||
//otherwise, binding failed
|
||||
else
|
||||
result = false;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void TextureManager::UnloadAllTextures()
|
||||
{
|
||||
//start at the begginning of the texture map
|
||||
std::map<unsigned int, GLuint>::iterator i = m_texID.begin();
|
||||
|
||||
//Unload the textures untill the end of the texture map is found
|
||||
while(i != m_texID.end())
|
||||
UnloadTexture(i->first);
|
||||
|
||||
//clear the texture map
|
||||
m_texID.clear();
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
//**********************************************
|
||||
//Singleton Texture Manager class
|
||||
//Written by Ben English
|
||||
//benjamin.english@oit.edu
|
||||
//
|
||||
//For use with OpenGL and the FreeImage library
|
||||
//**********************************************
|
||||
|
||||
#ifndef TextureManager_H
|
||||
#define TextureManager_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <gl/gl.h>
|
||||
#include "FreeImage.h"
|
||||
#include <map>
|
||||
|
||||
class TextureManager
|
||||
{
|
||||
public:
|
||||
static TextureManager* Inst();
|
||||
virtual ~TextureManager();
|
||||
|
||||
//load a texture an make it the current texture
|
||||
//if texID is already in use, it will be unloaded and replaced with this texture
|
||||
bool LoadTexture(const char* filename, //where to load the file from
|
||||
const unsigned int texID, //arbitrary id you will reference the texture by
|
||||
//does not have to be generated with glGenTextures
|
||||
GLenum image_format = GL_RGB, //format the image is in
|
||||
GLint internal_format = GL_RGB, //format to store the image in
|
||||
GLint level = 0, //mipmapping level
|
||||
GLint border = 0); //border size
|
||||
|
||||
//free the memory for a texture
|
||||
bool UnloadTexture(const unsigned int texID);
|
||||
|
||||
//set the current texture
|
||||
bool BindTexture(const unsigned int texID);
|
||||
|
||||
//free all texture memory
|
||||
void UnloadAllTextures();
|
||||
|
||||
protected:
|
||||
TextureManager();
|
||||
TextureManager(const TextureManager& tm);
|
||||
TextureManager& operator=(const TextureManager& tm);
|
||||
|
||||
static TextureManager* m_inst;
|
||||
std::map<unsigned int, GLuint> m_texID;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,31 @@
|
||||
Hello everyone, this is my 2D texture manager class for OpenGL using the FreeImage Library.
|
||||
|
||||
Requirements:
|
||||
--------------------
|
||||
OpenGL
|
||||
STL map class
|
||||
FreeImage (included)
|
||||
|
||||
|
||||
Usage
|
||||
--------------------
|
||||
To load a texture, simply call the LoadTexture function:
|
||||
|
||||
TextureManager::Inst()->LoadTexture("img\\bg.jpg", BACKGROUND_IMAGE_ID);
|
||||
|
||||
This also binds the loaded texture as the current texture, so after calling it you may make any calls to glTexParameter you may need to specify the properties of the texture.
|
||||
|
||||
When you are rendering, just call the TextureManager's BindImage function instead of glBindImage:
|
||||
|
||||
TextureManager::Inst()->BindImage(BACKGROUND_IMAGE_ID);
|
||||
|
||||
and then do your rendering as normal.
|
||||
--------------------
|
||||
|
||||
|
||||
Feel free to distribute this as you like, but mind the FreeImage licence included in license-fi.txt, and please don't take credit for my code. If you modify it, be sure to mention me (Ben English) somewhere.
|
||||
|
||||
Please send any comments or suggestions to me at benjamin.english@oit.edu
|
||||
|
||||
|
||||
Thanks to Herve Drolon for the FreeImage library, I've found it to be very useful!
|
@ -0,0 +1,253 @@
|
||||
// ==========================================================
|
||||
// Loader/Saver Plugin Cradle
|
||||
//
|
||||
// Design and implementation by
|
||||
// - Floris van den Berg (flvdberg@wxs.nl)
|
||||
// - Hervé Drolon (drolon@infonie.fr)
|
||||
//
|
||||
// This file is part of FreeImage 3
|
||||
//
|
||||
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
|
||||
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
|
||||
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
|
||||
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
|
||||
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
|
||||
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
|
||||
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
|
||||
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
|
||||
// THIS DISCLAIMER.
|
||||
//
|
||||
// Use at your own risk!
|
||||
// ==========================================================
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "FreeImage.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
// ==========================================================
|
||||
|
||||
BOOL APIENTRY
|
||||
DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH :
|
||||
case DLL_PROCESS_DETACH :
|
||||
case DLL_THREAD_ATTACH :
|
||||
case DLL_THREAD_DETACH :
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ==========================================================
|
||||
// Plugin Interface
|
||||
// ==========================================================
|
||||
|
||||
static int s_format_id;
|
||||
|
||||
// ==========================================================
|
||||
// Plugin Implementation
|
||||
// ==========================================================
|
||||
|
||||
/**
|
||||
Returns the format string for the plugin. Each plugin,
|
||||
both internal in the DLL and external in a .fip file, must have
|
||||
a unique format string to be addressable.
|
||||
*/
|
||||
|
||||
static const char * DLL_CALLCONV
|
||||
Format() {
|
||||
return "CRADLE";
|
||||
}
|
||||
|
||||
/**
|
||||
Returns a description string for the plugin. Though a
|
||||
description is not necessary per-se,
|
||||
it is advised to return an unique string in order to tell the
|
||||
user what type of bitmaps this plugin will read and/or write.
|
||||
*/
|
||||
|
||||
static const char * DLL_CALLCONV
|
||||
Description() {
|
||||
return "Here comes the description for your image loader/saver";
|
||||
}
|
||||
|
||||
/**
|
||||
Returns a comma separated list of file extensions indicating
|
||||
what files this plugin can open. no spaces or whatsoever are allowed.
|
||||
The list, being used by FreeImage_GetFIFFromFilename, is usually
|
||||
used as a last resort in finding the type of the bitmap we
|
||||
are dealing with. Best is to check the first few bytes on
|
||||
the low-level bits level first and compare them with a known
|
||||
signature . If this fails, FreeImage_GetFIFFromFilename can be
|
||||
used.
|
||||
*/
|
||||
|
||||
static const char * DLL_CALLCONV
|
||||
Extension() {
|
||||
return "ext1,ext2";
|
||||
}
|
||||
|
||||
/**
|
||||
RegExpr is only needed for the Qt wrapper
|
||||
It allows the Qt mechanism for loading bitmaps to identify the bitmap
|
||||
*/
|
||||
static const char * DLL_CALLCONV
|
||||
RegExpr() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns a MIME content type string for that format (MIME stands
|
||||
for Multipurpose Internet Mail Extension).
|
||||
*/
|
||||
static const char * DLL_CALLCONV
|
||||
MimeType() {
|
||||
return "image/myformat";
|
||||
}
|
||||
|
||||
/**
|
||||
FreeImage's internal way of seeing if a bitmap is of the desired type.
|
||||
When the type of a bitmap is to be retrieved, FreeImage runs Validate
|
||||
for each registered plugin until one returns true. If a plugin doesn't
|
||||
have a validate function, a return value of false is assumed.
|
||||
|
||||
You can always force to use a particular plugin by directly specifying
|
||||
it on the command line, but this can result in a dead DLL if the plugin
|
||||
was not made for the bitmap.
|
||||
*/
|
||||
static BOOL DLL_CALLCONV
|
||||
Validate(FreeImageIO &io, fi_handle handle) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
SupportsExportDepth is the first in a possible range of new plugin functions
|
||||
to ask specific information to that plugin. This function returns TRUE if it
|
||||
can save a bitmap in the required bitdepth. If it can't the bitmap has to be
|
||||
converted by the user or another plugin has to be chosen.
|
||||
*/
|
||||
static BOOL DLL_CALLCONV
|
||||
SupportsExportDepth(int depth) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns TRUE if the plugin belonging to the given FREE_IMAGE_FORMAT can save a
|
||||
bitmap in the desired data type, returns FALSE otherwise. Currently, TIFF is the only plugin
|
||||
able to save all non-standard images. The PNG plugin is able to save unsigned 16-bit
|
||||
images.
|
||||
*/
|
||||
static BOOL DLL_CALLCONV
|
||||
SupportsExportType(FREE_IMAGE_TYPE type) {
|
||||
return (type == FIT_BITMAP) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
SupportsICCProfiles informs FreeImage that a plugin supports ICC profiles.
|
||||
This function returns TRUE if the plugin can load and save a profile.
|
||||
ICC profile information is accessed via freeimage->get_icc_profile_proc(dib)
|
||||
*/
|
||||
static BOOL DLL_CALLCONV
|
||||
SupportsICCProfiles() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
Loads a bitmap into memory. On entry it is assumed that
|
||||
the bitmap to be loaded is of the correct type. If the bitmap
|
||||
is of an incorrect type, the plugin might not gracefully fail but
|
||||
crash or enter an endless loop. It is also assumed that all
|
||||
the bitmap data is available at one time. If the bitmap is not complete,
|
||||
for example because it is being downloaded while loaded, the plugin
|
||||
might also not gracefully fail.
|
||||
|
||||
The Load function has the following parameters:
|
||||
|
||||
The first parameter (FreeImageIO *io) is a structure providing
|
||||
function pointers in order to make use of FreeImage's IO redirection. Using
|
||||
FreeImage's file i/o functions instead of standard ones it is garantueed
|
||||
that all bitmap types, both current and future ones, can be loaded from
|
||||
memory, file cabinets, the internet and more. The second parameter (fi_handle handle)
|
||||
is a companion of FreeImageIO and can be best compared with the standard FILE* type,
|
||||
in a generalized form.
|
||||
|
||||
The third parameter (int page) indicates wether we will be loading a certain page
|
||||
in the bitmap or if we will load the default one. This parameter is only used if
|
||||
the plugin supports multi-paged bitmaps, e.g. cabinet bitmaps that contain a series
|
||||
of images or pages. If the plugin does support multi-paging, the page parameter
|
||||
can contain either a number higher or equal to 0 to load a certain page, or -1 to
|
||||
load the default page. If the plugin does not support multi-paging,
|
||||
the page parameter is always -1.
|
||||
|
||||
The fourth parameter (int flags) manipulates the load function to load a bitmap
|
||||
in a certain way. Every plugin has a different flag parameter with different meanings.
|
||||
|
||||
The last parameter (void *data) can contain a special data block used when
|
||||
the file is read multi-paged. Because not every plugin supports multi-paging
|
||||
not every plugin will use the data parameter and it will be set to NULL.However,
|
||||
when the plugin does support multi-paging the parameter contains a pointer to a
|
||||
block of data allocated by the Open function.
|
||||
*/
|
||||
|
||||
static FIBITMAP * DLL_CALLCONV
|
||||
Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static BOOL DLL_CALLCONV
|
||||
Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ==========================================================
|
||||
// Init
|
||||
// ==========================================================
|
||||
|
||||
/**
|
||||
Initialises the plugin. The first parameter (Plugin *plugin)
|
||||
contains a pointer to a pre-allocated Plugin structure
|
||||
wherein pointers to the available plugin functions
|
||||
has to be stored. The second parameter (int format_id) is an identification
|
||||
number that the plugin may use to show plugin specific warning messages
|
||||
or other information to the user. The plugin number
|
||||
is generated by FreeImage and can differ everytime the plugin is
|
||||
initialised.
|
||||
|
||||
If you want to create your own plugin you have to take some
|
||||
rules into account. Plugin functions have to be compiled
|
||||
__stdcall using the multithreaded c runtime libraries. Throwing
|
||||
exceptions in plugin functions is allowed, as long as those exceptions
|
||||
are being caught inside the same plugin. It is forbidden for a plugin
|
||||
function to directly call FreeImage functions or to allocate memory
|
||||
and pass it to the main DLL. Exception to this rule is the special file data
|
||||
block that may be allocated the Open function. Allocating a FIBITMAP inside a
|
||||
plugin can be using the function allocate_proc in the FreeImage structure,
|
||||
which will allocate the memory using the DLL's c runtime library.
|
||||
*/
|
||||
|
||||
void DLL_CALLCONV
|
||||
Init(Plugin *plugin, int format_id) {
|
||||
s_format_id = format_id;
|
||||
|
||||
plugin->format_proc = Format;
|
||||
plugin->description_proc = Description;
|
||||
plugin->extension_proc = Extension;
|
||||
plugin->regexpr_proc = RegExpr;
|
||||
plugin->open_proc = NULL;
|
||||
plugin->close_proc = NULL;
|
||||
plugin->pagecount_proc = NULL;
|
||||
plugin->pagecapability_proc = NULL;
|
||||
plugin->load_proc = Load;
|
||||
plugin->save_proc = Save;
|
||||
plugin->validate_proc = Validate;
|
||||
plugin->mime_proc = MimeType;
|
||||
plugin->supports_export_bpp_proc = SupportsExportDepth;
|
||||
plugin->supports_export_type_proc = SupportsExportType;
|
||||
plugin->supports_icc_profiles_proc = SupportsICCProfiles;
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
// ==========================================================
|
||||
// JBIG Plugin
|
||||
//
|
||||
// Design and implementation by
|
||||
// - Floris van den Berg (flvdberg@wxs.nl)
|
||||
//
|
||||
// This file is part of FreeImage 3
|
||||
//
|
||||
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
|
||||
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
|
||||
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
|
||||
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
|
||||
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
|
||||
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
|
||||
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
|
||||
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
|
||||
// THIS DISCLAIMER.
|
||||
//
|
||||
// Use at your own risk!
|
||||
// ==========================================================
|
||||
|
||||
#ifndef PLUGINCRADLE_H
|
||||
#define PLUGINCRADLE_H
|
||||
|
||||
#ifdef PLUGINCRADLE_EXPORTS
|
||||
#define PLUGIN_API __declspec(dllexport)
|
||||
#else
|
||||
#define PLUGIN_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
struct Plugin;
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
#define DLL_CALLCONV __stdcall
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
extern "C" {
|
||||
PLUGIN_API void DLL_CALLCONV Init(Plugin *plugin, int format_id);
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,236 @@
|
||||
=====================================================================
|
||||
Using the FreeImage library with the MinGW Compiler Suite
|
||||
=====================================================================
|
||||
|
||||
This file describes how to use the precompiled FreeImage library
|
||||
FreeImage.dll with the MinGW port of the GNU Compiler Collection
|
||||
(GCC), how to build this library from source using MinGW and how
|
||||
to use this MinGW-built library with Microsoft Visual Studio.
|
||||
|
||||
Contents:
|
||||
|
||||
I. Prerequisites
|
||||
|
||||
1. Using the precompiled FreeImage library with MinGW
|
||||
|
||||
2. Building the FreeImage library with MinGW
|
||||
|
||||
3. Using the MinGW FreeImage library with Microsoft Visual Studio
|
||||
|
||||
4. Useful links
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
I. Prerequisites
|
||||
=====================================================================
|
||||
|
||||
The procedures described in this document have been developed and
|
||||
tested using the following free tools:
|
||||
|
||||
1. MinGW GCC Version 4.4.0 (Core and C++ including required libs)
|
||||
2. MinGW GNU Binutils Version 2.19.1
|
||||
3. MinGW GNU Make Version 3.81-20080326-3
|
||||
4. MinGW Runtime Version 3.15.2
|
||||
5. MinGW API for MS-Windows Version 3.13
|
||||
6. GnuWin32 Package CoreUtils Version 5.3.0 (only for building)
|
||||
7. GnuWin32 Package Sed Version 4.2 (only for creating the GCC
|
||||
import library)*
|
||||
|
||||
* Sed is only needed to create a GCC-native import library from
|
||||
the MSVC import library FreeImage.lib. However, since MinGW now
|
||||
supports linking against MSVC lib files, this process seems to
|
||||
be obsolete. See section 1.
|
||||
|
||||
Basically, no version dependent capabilities are used so, this
|
||||
should also work with older versions of the tools mentioned above.
|
||||
Similarly, the GnuWin32 packages (which I just prefer over MSYS)
|
||||
could likely be replaced by a properly installed MSYS environment.
|
||||
|
||||
Furthermore, the following preconditions should be met:
|
||||
|
||||
1. The folders 'bin' under both the MinGW and the GnuWin32
|
||||
installation directory should have been added to the PATH
|
||||
environment variable. Likely it is best adding these
|
||||
directories permanently to PATH through the System
|
||||
Properties dialog on the Control Panel.
|
||||
|
||||
2. The MinGW Make package only provides a 'mingw32-make.exe'
|
||||
executable. There is no alias 'make.exe'. However, make is
|
||||
preconfigured to use 'make' as the default $(MAKE) command.
|
||||
This seems to be a bug in the MinGW GNU Make distribution.
|
||||
Thus, a copy of 'mingw32-make.exe' named 'make.exe' should
|
||||
be placed into MinGW's 'bin' directory.
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
1. Using the precompiled FreeImage library with MinGW
|
||||
=====================================================================
|
||||
|
||||
When using functions from C/C++, that reside in a DLL, the linker
|
||||
needs a so called import library, which specifies, how to
|
||||
dynamically link these external functions during runtime. However,
|
||||
different linkers use different types or formats of these import
|
||||
libraries.
|
||||
|
||||
Since the precompiled FreeImage library was build with Microsoft
|
||||
Visual Studio, in the past, some extra work was required to use it
|
||||
from MinGW. An import library, that was compatible with GNU ld,
|
||||
must have been created first.
|
||||
|
||||
However, for several MinGW versions, the GNU linker ld also
|
||||
supports linking against Microsoft Visual C++ import libraries
|
||||
directly. So, this effectively makes any circulating HOWTO's on
|
||||
how to create a GCC-compatible import library from a MSVC lib file
|
||||
more or less obsolete. Additionally, MinGW does not require the
|
||||
GCC/Linux usual lib prefix for libraries, so linking with MinGW
|
||||
against the precompiled FreeImage DLL is as easy as with MSVC:
|
||||
|
||||
1.) Open a DOS shell (run application cmd.exe)
|
||||
|
||||
2.) Ensure, that the 'bin' folder of MinGW is added to the PATH
|
||||
environment variable (see Prerequisites).
|
||||
|
||||
3.) Link directly against the supplied lib file:
|
||||
|
||||
C:\>gcc -oFreeImageTest.exe FreeImageTest.c -lFreeImage
|
||||
|
||||
Nonetheless, for the sake of completeness, the following steps
|
||||
describe how to create a native GCC import library:
|
||||
|
||||
1.) Open a DOS shell (run application cmd.exe)
|
||||
|
||||
2.) Ensure, that the 'bin' folders of both MinGW and GnuWin32 are
|
||||
added to the PATH environment variable (see Prerequisites).
|
||||
|
||||
3.) Create a .def file 'libfreeimage.def', that contains all symbols
|
||||
exported by the FreeImage library:
|
||||
|
||||
C:\>pexports FreeImage.dll | sed "s/^_//" > libfreeimage.def
|
||||
|
||||
4.) Create the GCC compatible import library 'libfreeimage.a':
|
||||
|
||||
C:\>dlltool --add-underscore -d libfreeimage.def -l libfreeimage.a
|
||||
|
||||
5.) Use this library to link against with GCC:
|
||||
|
||||
C:\>gcc -oFreeImageTest.exe FreeImageTest.c -lfreeimage
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
2. Building the FreeImage library with MinGW
|
||||
=====================================================================
|
||||
|
||||
You *do not* need to have any other third party library (like
|
||||
libjpeg, libpng, libtiff, libmng and zlib and others) installed on
|
||||
your system in order to compile and use the library. FreeImage uses
|
||||
its own versions of these libraries. This way, you can be sure that
|
||||
FreeImage will always use the latest and properly tested versions
|
||||
of of these third party libraries.
|
||||
|
||||
In order to build the FreeImage library under Windows with MinGW
|
||||
(GCC), ensure that all the prerequisites mentioned above are met.
|
||||
The MinGW makefile aims to build a Windows DLL, that differs as
|
||||
least as possible from the precompiled library that comes with the
|
||||
FreeImage distribution. Thus, the build process also includes the
|
||||
DLL version resource as well as the __stdcall attribute for all the
|
||||
exported functions, including the MSVC-like function decorations
|
||||
_FuncName@nn.
|
||||
|
||||
When building the FreeImage DLL, of course, an import library is
|
||||
generated, too. However, this input library is not in GCC's native
|
||||
format, but in MSVC lib format, which makes it usable from both
|
||||
MinGW and Microsoft Visual Studio with no further processing.
|
||||
|
||||
The MinGW makefile can also be used to build a static library.
|
||||
However, due to the different function export attributes needed
|
||||
for both the dynamic and the shared library (DLL), this requires
|
||||
a separate invocation of make, which in turn needs to rebuild every
|
||||
source file after switching from dynamic to static and vice versa.
|
||||
So, a 'make clean' is required each time, the library type is
|
||||
changed.
|
||||
|
||||
The type of library to build is specified by a variable named
|
||||
FREEIMAGE_LIBRARY_TYPE, which may either be set directly in the
|
||||
Makefile.mingw near line 18 or may be specified as an environment
|
||||
variable. This variable may either take SHARED or STATIC to build
|
||||
a dynamic link library (DLL) or a static library respectively.
|
||||
Since this value is used to dynamically form the actual make target
|
||||
internally, only uppercase values are valid. Defaults to SHARED.
|
||||
|
||||
The MinGW makefile also supports the 'install' target. However,
|
||||
this only copies the FreeImage dynamic link library (DLL) from the
|
||||
Dist folder into the %SystemRoot%\system32 folder. So, invoking this
|
||||
target only makes sense, if the DLL has been built before.
|
||||
|
||||
Since there is neither a common system wide 'include' nor a 'lib'
|
||||
directory available under Windows, the FreeImage header file
|
||||
FreeImage.h as well as both the static library and the DLL import
|
||||
library FreeImage.lib just remain in the 'Dist' folder.
|
||||
|
||||
The following procedure creates the FreeImage dynamic link library
|
||||
(DLL) from the sources, installs it and also creates a static
|
||||
FreeImage library:
|
||||
|
||||
1.) Open a DOS shell (run application cmd.exe)
|
||||
|
||||
2.) Ensure, that the 'bin' folders of both MinGW and GnuWin32 are
|
||||
added to the PATH environment variable (see Prerequisites).
|
||||
|
||||
3.) Create the FreeImage dynamic link library (DLL):
|
||||
|
||||
C:\>make
|
||||
|
||||
4.) Install the FreeImage dynamic link library (DLL):
|
||||
|
||||
C:\>make install
|
||||
|
||||
5.) Clean all files produced by the recent build process:
|
||||
|
||||
C:\>make clean
|
||||
|
||||
6.) Create a static FreeImage library:
|
||||
|
||||
C:\>set FREEIMAGE_LIBRARY_TYPE=STATIC
|
||||
C:\>make
|
||||
|
||||
You should be able to link progams with the -lFreeImage option
|
||||
after the shared library is compiled and installed. You can also
|
||||
link statically against FreeImage.a from MinGW.
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
3. Using the MinGW FreeImage library with Microsoft Visual Studio
|
||||
=====================================================================
|
||||
|
||||
Since the MinGW makefile creates an import library in MSVC's lib
|
||||
format, the produced shared library (DLL) can be used from both
|
||||
MinGW and Microsoft Visual Studio with no further adaption. Just
|
||||
link to the import library FreeImage.lib from either MinGW or
|
||||
Microsoft Visual Studio.
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
4. Useful links
|
||||
=====================================================================
|
||||
|
||||
- The MinGW homepage:
|
||||
http://www.mingw.org/
|
||||
|
||||
- The GnuWin32 homepage:
|
||||
http://gnuwin32.sourceforge.net/
|
||||
|
||||
- The GCC homepage and online documentation:
|
||||
http://gcc.gnu.org/
|
||||
http://gcc.gnu.org/onlinedocs/
|
||||
|
||||
- The GNU Binutils homepage and online documentation:
|
||||
http://www.gnu.org/software/binutils/
|
||||
http://sourceware.org/binutils/docs-2.19/
|
||||
|
||||
- The GNU Make homepage and online documentation:
|
||||
http://www.gnu.org/software/make/
|
||||
http://www.gnu.org/software/make/manual/make.html
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,128 @@
|
||||
What's New for FreeImage Delphi Wrapper
|
||||
|
||||
* : fixed
|
||||
- : removed
|
||||
! : changed
|
||||
+ : added
|
||||
|
||||
June 3, 2016
|
||||
+ [Lorenzo Monti] added preprocessor tests for Delphi 10.1 Berlin
|
||||
|
||||
January 6, 2016
|
||||
+ [Lorenzo Monti] updated wrapper for FreeImage 3.18.0
|
||||
+ [Lorenzo Monti] added preprocessor tests for Delphi 10 Seattle
|
||||
|
||||
September 17, 2015
|
||||
+ [Lorenzo Monti] updated wrapper for FreeImage 3.17.0
|
||||
+ [Lorenzo Monti] added preprocessor tests for Delphi XE7..XE8
|
||||
|
||||
May 5, 2014
|
||||
+ [Lorenzo Monti] updated wrapper for FreeImage 3.16.1
|
||||
+ [Lorenzo Monti] added preprocessor tests for Delphi XE2..XE6
|
||||
+ [Lorenzo Monti] merged changes for OSX compatibility (submitted by Maurício)
|
||||
|
||||
December 8, 2012
|
||||
+ [Lorenzo Monti] updated wrapper for FreeImage 3.15.4
|
||||
|
||||
June 4, 2012
|
||||
+ [Lorenzo Monti] updated wrapper for FreeImage 3.15.3
|
||||
|
||||
March 4, 2011
|
||||
* [Jean-Marc Bottura] some bugfixes in FreeBitmap.pas
|
||||
+ [Jean-Marc Bottura] added support for 64 bit compilers
|
||||
|
||||
February 15, 2011
|
||||
+ [Lorenzo Monti] updated wrapper for FreeImage 3.15.0
|
||||
|
||||
January 4, 2011
|
||||
+ [Lorenzo Monti] updated ImagePreview demo to support latest Graphics32 components (1.9) and Delphi 2010 / XE
|
||||
|
||||
November 12, 2010
|
||||
+ [Lorenzo Monti] updated wrapper for FreeImage 3.14.1
|
||||
+ [Lorenzo Monti] added Delphi XE support
|
||||
|
||||
July 29, 2010
|
||||
+ [Lorenzo Monti] added Free Pascal / Lazarus 32 bit support
|
||||
|
||||
July 14, 2010
|
||||
+ [Lorenzo Monti] updated wrapper for FreeImage 3.13.1
|
||||
* [Lorenzo Monti] fixed declaration of FreeImageIO functions (FI_ReadProc, FI_WriteProc, FI_SeekProc, FI_TellProc)
|
||||
! [Lorenzo Monti] renamed structure PluginStruct to Plugin, according to FreeImage.h
|
||||
* [Lorenzo Monti] fixed declaration of JPEG_CMYK constant
|
||||
* [Lorenzo Monti] fixed declaration of type FreeImage_OutputMessageFunction
|
||||
* [Lorenzo Monti] fixed declaration of FreeImage_OutputMessageProc
|
||||
+ [Lorenzo Monti] added wrapper for FreeImage_OutputMessageProc for older Delphi compilers (<6) not supporting varargs
|
||||
* [Lorenzo Monti] fixed declaration of FreeImage_LookupX11Color and FreeImage_LookupSVGColor
|
||||
! [Lorenzo Monti] changed declaration of FreeImage_GetPixelIndex, FreeImage_GetPixelColor, FreeImage_SetPixelIndex, FreeImage_SetPixelColor
|
||||
! [Lorenzo Monti] changed declaration of FreeImage_GetInfo
|
||||
! [Lorenzo Monti] changed declaration of FreeImage_GetICCProfile, FreeImage_CreateICCProfile, FreeImage_DestroyICCProfile
|
||||
* [Lorenzo Monti] fixed declaration of FreeImage_SetComplexChannel
|
||||
+ [Lorenzo Monti] added Delphi 2010 support
|
||||
+ [Lorenzo Monti] added Version.inc to determine compiler version
|
||||
! [Lorenzo Monti] moved all "external" definitions to implementation section
|
||||
! [Lorenzo Monti] changed FreeBitmap.pas, FreeUtils.pas and TargaImage.pas to reflect changes in the FreeImage.pas unit
|
||||
|
||||
July 17, 2006
|
||||
+ [Hervé Drolon] added FIF_FAXG3 and FIF_SGI definitions, added FreeImage_MakeThumbnail definition.
|
||||
|
||||
January 20, 2006
|
||||
! [Anatoliy Pulyaevskiy] updated WinBitmap demo
|
||||
* [Anatoliy Pulyaevskiy] fixed TFreeBitmap.ConvertToStandartType renamed to TFreeBitmap.ConvertToStandardType
|
||||
* [Anatoliy Pulyaevskiy] fixed using of SetFreeImageMarker (only for HDR dib)
|
||||
|
||||
October 19, 2005
|
||||
+ [Anatoliy Pulyaevskiy] updated wrapper for FreeImage 3.8.0
|
||||
+ [Anatoliy Pulyaevskiy] added Delphi 5 support
|
||||
+ [Anatoliy Pulyaevskiy] added TFreeBitmap.OnChanging event
|
||||
! [Anatoliy Pulyaevskiy] changed declaration of TFreeBitmap.Assign method
|
||||
+ [Anatoliy Pulyaevskiy] added TFreeBitmap.CanSave function
|
||||
! [Anatoliy Pulyaevskiy] property TFreeBitmap.Dib now have read/write access
|
||||
+ [Anatoliy Pulyaevskiy] added TFreeTag class incapsulating FreeImage FITAG type
|
||||
|
||||
August 5, 2005
|
||||
* [kaare-nysite] fixed the prototype of FreeImage_ConvertFromRawBits
|
||||
|
||||
June 21, 2005
|
||||
* [Maarten Veerman] fixed the prototype of FreeImage_OpenMultiBitmap
|
||||
|
||||
February 17, 2005 - Version 1.3.0
|
||||
+ [Anatoliy Pulyaevskiy] updated the wrapper for FreeImage 3.6.0
|
||||
! [Anatoliy Pulyaevskiy] FreeImage.pas unit has been reworked
|
||||
|
||||
January 14, 2005 - Version 1.2.1
|
||||
+ [Anatoliy Pulyaevskiy] updated the wrapper for FreeImage 3.5.3
|
||||
+ [Anatoliy Pulyaevskiy] added TFreeBitmap.SetHorizontalResolution and TFreeBitmap.SetVerticalResolution
|
||||
+ [Anatoliy Pulyaevskiy] added TFreeBitmap.MakeThumbnail procedure ( an adapted version of function given by Enzo Costantini)
|
||||
+ [Enzo Costantini] added FIU_GetFIFType utility function
|
||||
+ [Enzo Costantini] added TFreeWinBitmap.CopyToBitmapH function
|
||||
* [Anatoliy Pulyaevskiy] fixed TFreeBitmap.Rotate (fix from FreeImage CVS)
|
||||
+ [Anatoliy Pulyaevskiy] added TFreeBitmap.ConvertToStandartType
|
||||
|
||||
December 20, 2004 - Version 1.2.0
|
||||
+ [Anatoliy Pulyaevskiy] added MultiBitmap Demo
|
||||
* [Anatoliy Pulyaevskiy] fixed TFreeMultiBitmap.LockPage due to error with Locking/Unlocking pages
|
||||
+ [Anatoliy Pulyaevskiy] added TFreeBitmap.ConvertTo4Bits
|
||||
* [Anatoliy Pulyaevskiy] TFreeBitmap.ConvertToGrayScale fixed converting bitmaps with FIC_MINISWHITE color type
|
||||
* [Anatoliy Pulyaevskiy] fixed TFreeWinBitmap.DrawEx FDisplayDib deleting
|
||||
+ [Anatoliy Pulyaevskiy] updated the wrapper for FreeImage 3.5.2
|
||||
|
||||
November 12, 2004 - Version 1.1.0
|
||||
+ [Anatoliy Pulyaevskiy] added TFreeBitmap.Assign(Source: PFIBITMAP)
|
||||
- [Anatoliy Pulyaevskiy] removed TFreeBitmap.SetDib
|
||||
! [Anatoliy Pulyaevskiy] TFreeBitmap.Dib property now read-only
|
||||
* [Anatoliy Pulyaevskiy] TFreeMultiBitmap.UnlockPage implemented
|
||||
* [Anatoliy Pulyaevskiy] fixed TFreeBitmap.Rescale not applies changes
|
||||
|
||||
November 8, 2004 - Version 1.0.0
|
||||
+ [Anatoliy Pulyaevskiy] added Delphi version of FreeImagePlus
|
||||
+ [Anatoliy Pulyaevskiy] updated the wrapper for FreeImage 3.5.0
|
||||
|
||||
January 7, 2004
|
||||
+ [Tommy] added TargaImage unit
|
||||
|
||||
October 28, 2003
|
||||
+ [Peter Byström] updated the wrapper for FreeImage 3.0.2
|
||||
|
||||
August 9, 2003
|
||||
+ [Simon Beavis] added a wrapper for FreeImage 2.6.1
|
||||
|
@ -0,0 +1,13 @@
|
||||
del /S *.~*
|
||||
del /S *.dcu
|
||||
del /S *.dsk
|
||||
del /S *.cfg
|
||||
del /S *.dof
|
||||
del /S *.obj
|
||||
del /S *.hpp
|
||||
del /S *.ddp
|
||||
del /S *.mps
|
||||
del /S *.mpt
|
||||
del /S *.bak
|
||||
del /S *.exe
|
||||
del /S *.stat
|
@ -0,0 +1,13 @@
|
||||
program ImagePreview;
|
||||
|
||||
uses
|
||||
Forms,
|
||||
MainFrm in 'MainFrm.pas' {MainForm};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
end.
|
Binary file not shown.
@ -0,0 +1,135 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 304
|
||||
Top = 165
|
||||
Width = 467
|
||||
Height = 405
|
||||
Caption = 'Image Preview'
|
||||
Color = clWhite
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'MS Sans Serif'
|
||||
Font.Style = []
|
||||
KeyPreview = True
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnKeyUp = FormKeyUp
|
||||
OnMouseWheel = ScrollBoxMouseWheel
|
||||
OnShow = FormShow
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object ImgView32: TImgView32
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 459
|
||||
Height = 371
|
||||
Align = alClient
|
||||
ParentShowHint = False
|
||||
PopupMenu = PopupMenu
|
||||
Scale = 1
|
||||
ScrollBars.Color = clScrollBar
|
||||
ScrollBars.ShowHandleGrip = True
|
||||
ScrollBars.Style = rbsDefault
|
||||
ShowHint = True
|
||||
SizeGrip = sgAuto
|
||||
TabOrder = 0
|
||||
OnScroll = ImgView32Scroll
|
||||
object AlphaView: TImgView32
|
||||
Left = 8
|
||||
Top = 8
|
||||
Width = 161
|
||||
Height = 145
|
||||
Scale = 1
|
||||
ScrollBars.Color = clScrollBar
|
||||
ScrollBars.ShowHandleGrip = True
|
||||
ScrollBars.Style = rbsDefault
|
||||
SizeGrip = sgAuto
|
||||
TabOrder = 2
|
||||
Visible = False
|
||||
end
|
||||
end
|
||||
object PopupMenu: TPopupMenu
|
||||
Left = 304
|
||||
Top = 28
|
||||
object ZoomInItem: TMenuItem
|
||||
Caption = 'Zoom In'
|
||||
OnClick = ZoomInItemClick
|
||||
end
|
||||
object ZoomOutItem: TMenuItem
|
||||
Caption = 'Zoom Out'
|
||||
OnClick = ZoomOutItemClick
|
||||
end
|
||||
object ActualSizeItem: TMenuItem
|
||||
Caption = 'Actual Size'
|
||||
OnClick = ActualSizeItemClick
|
||||
end
|
||||
object N1: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object RotateClockwiseItem: TMenuItem
|
||||
Caption = 'Rotate Clockwise'
|
||||
OnClick = RotateClockwiseItemClick
|
||||
end
|
||||
object RotateAntiClockwiseItem: TMenuItem
|
||||
Caption = 'Rotate Anti-Clockwise'
|
||||
OnClick = RotateAntiClockwiseItemClick
|
||||
end
|
||||
object N4: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object FlipHorizontalItem: TMenuItem
|
||||
Caption = 'Flip Horizontal'
|
||||
OnClick = FlipHorizontalItemClick
|
||||
end
|
||||
object FilpVerticalItem: TMenuItem
|
||||
Caption = 'Filp Vertical'
|
||||
OnClick = FilpVerticalItemClick
|
||||
end
|
||||
object N3: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object ShowAlphaItem: TMenuItem
|
||||
Caption = 'Show Just Alpha Channel'
|
||||
OnClick = ShowAlphaItemClick
|
||||
end
|
||||
object ShowWithAlphaItem: TMenuItem
|
||||
Caption = 'Show With Alpha Channel'
|
||||
OnClick = ShowWithAlphaItemClick
|
||||
end
|
||||
object N2: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object OpenImageItem: TMenuItem
|
||||
Caption = 'Open New Image'
|
||||
OnClick = OpenImageItemClick
|
||||
end
|
||||
end
|
||||
object FilterTimer: TTimer
|
||||
Interval = 500
|
||||
OnTimer = FilterTimerTimer
|
||||
Left = 308
|
||||
Top = 84
|
||||
end
|
||||
object OpenDialog: TOpenDialog
|
||||
Filter =
|
||||
'All image files|*.bmp;*.cut;*.ico;*.iff;*.lbm;*.jng;*.jpg;*.jpeg' +
|
||||
';*.koa;*.mng;*.pbm;*.pcd;*.pcx;*.pgm;*.png;*.ppm;*.psd;*.ras;*.t' +
|
||||
'ga;*.tif;*.tiff;.wbmp;*.xbm;*.xpm)|Windows or OS/2 Bitmap File (' +
|
||||
'*.BMP)|*.BMP|Dr. Halo (*.CUT)|*.CUT|Windows Icon (*.ICO)|*.ICO|A' +
|
||||
'miga IFF (*.IFF, *.LBM)|*.IFF;*.LBM|JPEG Network Graphics (*.JNG' +
|
||||
')|*.JNG|Independent JPEG Group (*.JPG)|*.JPG|Commodore 64 Koala ' +
|
||||
'(*.KOA)|*.KOA|Multiple Network Graphics (*.MNG)|*.MNG|Portable B' +
|
||||
'itmap (*.PBM)|*.PBM|Kodak PhotoCD (*.PCD)|*.PCD|PCX bitmap forma' +
|
||||
't (*.PCX)|*.PCX|Portable Graymap (*.PGM)|*.PGM|Portable Network ' +
|
||||
'Graphics (*.PNG)|*.PNG|Portable Pixelmap (*.PPM)|*.PPM|Photoshop' +
|
||||
' (*.PSD)|*.PSD|Sun Rasterfile (*.RAS)|*.RAS|Targa files (*.TGA)|' +
|
||||
'*.TGA|Tagged Image File Format (*.TIF)|*.TIF;*.TIFF|Wireless Bit' +
|
||||
'map (*.WBMP)|*.WBMP|X11 Bitmap Format (*.XBM)|*.XBM|X11 Pixmap F' +
|
||||
'ormat (*.XPM)|*.XPM'
|
||||
Title = 'Open Image File'
|
||||
Left = 328
|
||||
Top = 228
|
||||
end
|
||||
end
|
@ -0,0 +1,524 @@
|
||||
unit MainFrm;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, Menus, ExtCtrls, Math, GR32, GR32_Image, GR32_Transforms,
|
||||
ExtDlgs;
|
||||
|
||||
type
|
||||
TMainForm = class(TForm)
|
||||
PopupMenu: TPopupMenu;
|
||||
ZoomInItem: TMenuItem;
|
||||
ZoomOutItem: TMenuItem;
|
||||
ActualSizeItem: TMenuItem;
|
||||
ImgView32: TImgView32;
|
||||
N1: TMenuItem;
|
||||
AlphaView: TImgView32;
|
||||
ShowAlphaItem: TMenuItem;
|
||||
RotateClockwiseItem: TMenuItem;
|
||||
RotateAntiClockwiseItem: TMenuItem;
|
||||
N3: TMenuItem;
|
||||
ShowWithAlphaItem: TMenuItem;
|
||||
N4: TMenuItem;
|
||||
FlipHorizontalItem: TMenuItem;
|
||||
FilpVerticalItem: TMenuItem;
|
||||
FilterTimer: TTimer;
|
||||
OpenImageItem: TMenuItem;
|
||||
N2: TMenuItem;
|
||||
OpenDialog: TOpenDialog;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure ZoomInItemClick(Sender: TObject);
|
||||
procedure ZoomOutItemClick(Sender: TObject);
|
||||
procedure ActualSizeItemClick(Sender: TObject);
|
||||
procedure ScrollBoxMouseWheel(Sender: TObject; Shift: TShiftState;
|
||||
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
|
||||
procedure FormKeyUp(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
procedure ShowAlphaItemClick(Sender: TObject);
|
||||
procedure RotateClockwiseItemClick(Sender: TObject);
|
||||
procedure RotateAntiClockwiseItemClick(Sender: TObject);
|
||||
procedure ShowWithAlphaItemClick(Sender: TObject);
|
||||
procedure FlipHorizontalItemClick(Sender: TObject);
|
||||
procedure FilpVerticalItemClick(Sender: TObject);
|
||||
procedure FilterTimerTimer(Sender: TObject);
|
||||
procedure ImgView32Scroll(Sender: TObject);
|
||||
procedure OpenImageItemClick(Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
OrigWidth : integer;
|
||||
OrigHeight : integer;
|
||||
BPP : longword;
|
||||
|
||||
procedure LoadImage( Name : string);
|
||||
procedure RecalcWindowSize;
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
MainForm: TMainForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
uses FreeImage, GR32_Resamplers;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
AlphaView.Visible := False;
|
||||
AlphaView.Align := alClient;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
// ...
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.FormShow(Sender: TObject);
|
||||
var
|
||||
Resampler: TKernelResampler;
|
||||
begin
|
||||
Resampler := TKernelResampler.Create(ImgView32.Bitmap);
|
||||
Resampler.Kernel := TSplineKernel.Create;
|
||||
if ParamCount = 1 then
|
||||
LoadImage(ParamStr(1));
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.LoadImage( Name : string);
|
||||
var
|
||||
dib : PFIBITMAP;
|
||||
PBH : PBITMAPINFOHEADER;
|
||||
PBI : PBITMAPINFO;
|
||||
t : FREE_IMAGE_FORMAT;
|
||||
Ext : string;
|
||||
BM : TBitmap;
|
||||
x, y : integer;
|
||||
BP : PLONGWORD;
|
||||
DC : HDC;
|
||||
begin
|
||||
try
|
||||
t := FreeImage_GetFileType(PAnsiChar(AnsiString(Name)), 16);
|
||||
|
||||
if t = FIF_UNKNOWN then
|
||||
begin
|
||||
// Check for types not supported by GetFileType
|
||||
Ext := UpperCase(ExtractFileExt(Name));
|
||||
if (Ext = '.TGA') or(Ext = '.TARGA') then
|
||||
t := FIF_TARGA
|
||||
else if Ext = '.MNG' then
|
||||
t := FIF_MNG
|
||||
else if Ext = '.PCD' then
|
||||
t := FIF_PCD
|
||||
else if Ext = '.WBMP' then
|
||||
t := FIF_WBMP
|
||||
else if Ext = '.CUT' then
|
||||
t := FIF_CUT
|
||||
else
|
||||
raise Exception.Create('The file "' + Name + '" cannot be displayed because SFM does not recognise the file type.');
|
||||
end;
|
||||
|
||||
dib := FreeImage_Load(t, PAnsiChar(AnsiString(name)), 0);
|
||||
if Dib = nil then
|
||||
Close;
|
||||
PBH := FreeImage_GetInfoHeader(dib);
|
||||
PBI := FreeImage_GetInfo(dib);
|
||||
|
||||
BPP := FreeImage_GetBPP(dib);
|
||||
|
||||
ShowWithAlphaItem.Enabled := BPP = 32;
|
||||
ShowAlphaItem.Enabled := BPP = 32;
|
||||
|
||||
if BPP = 32 then
|
||||
begin
|
||||
ImgView32.Bitmap.SetSize(FreeImage_GetWidth(dib), FreeImage_GetHeight(dib));
|
||||
|
||||
BP := PLONGWORD(FreeImage_GetBits(dib));
|
||||
for y := ImgView32.Bitmap.Height - 1 downto 0 do
|
||||
for x := 0 to ImgView32.Bitmap.Width - 1 do
|
||||
begin
|
||||
ImgView32.Bitmap.Pixel[x, y] := BP^;
|
||||
inc(BP);
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
BM := TBitmap.Create;
|
||||
|
||||
BM.Assign(nil);
|
||||
DC := GetDC(Handle);
|
||||
|
||||
BM.handle := CreateDIBitmap(DC,
|
||||
PBH^,
|
||||
CBM_INIT,
|
||||
PChar(FreeImage_GetBits(dib)),
|
||||
PBI^,
|
||||
DIB_RGB_COLORS);
|
||||
|
||||
ImgView32.Bitmap.Assign(BM);
|
||||
AlphaView.Bitmap.Assign(BM);
|
||||
|
||||
BM.Free;
|
||||
ReleaseDC(Handle, DC);
|
||||
end;
|
||||
FreeImage_Unload(dib);
|
||||
|
||||
OrigWidth := ImgView32.Bitmap.Width;
|
||||
OrigHeight := ImgView32.Bitmap.Height;
|
||||
|
||||
Caption := ExtractFileName( Name ) + ' (' + IntToStr(OrigWidth) +
|
||||
' x ' + IntToStr(OrigHeight) + ')';
|
||||
if BPP = 32 then
|
||||
Caption := Caption + ' + Alpha';
|
||||
|
||||
AlphaView.Bitmap.SetSize(OrigWidth, OrigWidth);
|
||||
|
||||
ImgView32.Hint := 'Name: ' + Name + #13 +
|
||||
'Width: ' + IntToStr(OrigWidth) + #13 +
|
||||
'Height: ' + IntToStr(OrigHeight) + #13 +
|
||||
'BPP: ' + IntToStr(BPP);
|
||||
|
||||
RecalcWindowSize;
|
||||
|
||||
Show;
|
||||
except
|
||||
on e:exception do
|
||||
begin
|
||||
Application.BringToFront;
|
||||
MessageDlg(e.message, mtInformation, [mbOK], 0);
|
||||
Close;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.ZoomInItemClick(Sender: TObject);
|
||||
begin
|
||||
FilterTimer.Enabled := False;
|
||||
if not (ImgView32.Bitmap.Resampler is TNearestResampler) then
|
||||
TNearestResampler.Create(ImgView32.Bitmap);
|
||||
FilterTimer.Enabled := True;
|
||||
|
||||
ImgView32.Scale := ImgView32.Scale * 2.0;
|
||||
RecalcWindowSize;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.ZoomOutItemClick(Sender: TObject);
|
||||
begin
|
||||
FilterTimer.Enabled := False;
|
||||
if not (ImgView32.Bitmap.Resampler is TNearestResampler) then
|
||||
TNearestResampler.Create(ImgView32.Bitmap);
|
||||
FilterTimer.Enabled := True;
|
||||
|
||||
ImgView32.Scale := ImgView32.Scale / 2.0;
|
||||
RecalcWindowSize;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.ActualSizeItemClick(Sender: TObject);
|
||||
begin
|
||||
FilterTimer.Enabled := False;
|
||||
if not (ImgView32.Bitmap.Resampler is TNearestResampler) then
|
||||
TNearestResampler.Create(ImgView32.Bitmap);
|
||||
FilterTimer.Enabled := True;
|
||||
|
||||
ImgView32.Scale := 1.0;
|
||||
|
||||
RecalcWindowSize;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.RecalcWindowSize;
|
||||
var
|
||||
Rect : TRect;
|
||||
CW, CH : integer;
|
||||
WSH, WSW : integer;
|
||||
TitleH : integer;
|
||||
BorderY : integer;
|
||||
BorderX : integer;
|
||||
begin
|
||||
CW := ImgView32.Bitmap.Width + GetSystemMetrics(SM_CXVSCROLL);
|
||||
CH := ImgView32.Bitmap.Height + GetSystemMetrics(SM_CYVSCROLL);
|
||||
|
||||
SystemParametersInfo( SPI_GETWORKAREA, 0, @Rect, 0);
|
||||
|
||||
WSH := Rect.Bottom - Rect.Top;
|
||||
WSW := Rect.Right - Rect.Left;
|
||||
TitleH := GetSystemMetrics(SM_CYCAPTION);
|
||||
BorderY := GetSystemMetrics(SM_CYSIZEFRAME) * 2;
|
||||
BorderX := GetSystemMetrics(SM_CXSIZEFRAME) * 2;
|
||||
|
||||
if (Top + CH + TitleH + BorderY > WSH) or (CH + TitleH + BorderY > WSH) then
|
||||
begin
|
||||
Top := Rect.Bottom - CH - BorderY;
|
||||
if Top < 0 then
|
||||
begin
|
||||
Top := 0;
|
||||
CH := WSH - TitleH - BorderY;
|
||||
CW := CW + GetSystemMetrics(SM_CXVSCROLL);
|
||||
|
||||
if CW + BorderX > WSW then
|
||||
CH := CH - GetSystemMetrics(SM_CYVSCROLL);
|
||||
end;
|
||||
end;
|
||||
|
||||
if (Left + CW + BorderX > WSW) or (CW + BorderX > WSW) then
|
||||
begin
|
||||
Left := Rect.Right - CW - BorderX;
|
||||
if Left < 0 then
|
||||
begin
|
||||
Left := 0;
|
||||
CW := WSW - BorderX;
|
||||
CH := CH + GetSystemMetrics(SM_CYVSCROLL);
|
||||
|
||||
if CH + TitleH + BorderY > WSH then
|
||||
CW := CW + GetSystemMetrics(SM_CXVSCROLL);
|
||||
end
|
||||
end;
|
||||
|
||||
ClientWidth := CW;
|
||||
ClientHeight := CH;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.ScrollBoxMouseWheel(Sender: TObject;
|
||||
Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
|
||||
var Handled: Boolean);
|
||||
begin
|
||||
FilterTimer.Enabled := False;
|
||||
if not (ImgView32.Bitmap.Resampler is TNearestResampler) then
|
||||
TNearestResampler.Create(ImgView32.Bitmap);
|
||||
FilterTimer.Enabled := True;
|
||||
|
||||
if WheelDelta < 0 then
|
||||
ImgView32.Scroll(0, 20)
|
||||
else
|
||||
ImgView32.Scroll(0, -20);
|
||||
Handled := True;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.FormKeyUp(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
var
|
||||
Amount : integer;
|
||||
begin
|
||||
FilterTimer.Enabled := False;
|
||||
if not (ImgView32.Bitmap.Resampler is TNearestResampler) then
|
||||
TNearestResampler.Create(ImgView32.Bitmap);
|
||||
FilterTimer.Enabled := True;
|
||||
|
||||
if ssShift in Shift then
|
||||
Amount := 20 * 2
|
||||
else
|
||||
Amount := 20;
|
||||
|
||||
case Key of
|
||||
VK_ESCAPE:
|
||||
Close;
|
||||
VK_UP:
|
||||
ImgView32.Scroll(0, -Amount);
|
||||
VK_DOWN:
|
||||
ImgView32.Scroll(0, Amount);
|
||||
VK_LEFT:
|
||||
ImgView32.Scroll(-Amount, 0);
|
||||
VK_RIGHT:
|
||||
ImgView32.Scroll(Amount, 0);
|
||||
VK_HOME:
|
||||
ImgView32.ScrollToCenter(0, 0);
|
||||
VK_END:
|
||||
ImgView32.ScrollToCenter(ImgView32.Bitmap.Width, ImgView32.Bitmap.Height);
|
||||
VK_NEXT:
|
||||
ImgView32.Scroll(0, (Trunc(ImgView32.Bitmap.Height div 4)));
|
||||
VK_PRIOR:
|
||||
ImgView32.Scroll(0, -(Trunc(ImgView32.Bitmap.Height div 4)));
|
||||
end;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.ShowAlphaItemClick(Sender: TObject);
|
||||
var
|
||||
x, y : integer;
|
||||
Col : TColor32;
|
||||
Alpha : TColor;
|
||||
begin
|
||||
if ShowAlphaItem.Checked then
|
||||
begin
|
||||
AlphaView.Visible := False;
|
||||
AlphaView.Bitmap.Delete;
|
||||
end
|
||||
else
|
||||
begin
|
||||
AlphaView.Bitmap.Width := ImgView32.Bitmap.Width;
|
||||
AlphaView.Bitmap.Height := ImgView32.Bitmap.Height;
|
||||
|
||||
for x := 0 to AlphaView.Bitmap.Width - 1 do
|
||||
for y := 0 to AlphaView.Bitmap.Height - 1 do
|
||||
begin
|
||||
Col := ImgView32.Bitmap.Pixel[x, y];
|
||||
Alpha := Col shr 24;
|
||||
AlphaView.Bitmap.Pixel[x, y] := Alpha + (Alpha shl 8) + (Alpha shl 16);
|
||||
end;
|
||||
AlphaView.Visible := True;
|
||||
end;
|
||||
ShowAlphaItem.Checked := not ShowAlphaItem.Checked;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.RotateClockwiseItemClick(Sender: TObject);
|
||||
var
|
||||
x : integer;
|
||||
y : integer;
|
||||
DestX : integer;
|
||||
DestY : integer;
|
||||
C : TColor32;
|
||||
begin
|
||||
AlphaView.Bitmap.Assign(ImgView32.Bitmap);
|
||||
|
||||
ImgView32.BeginUpdate;
|
||||
ImgView32.Bitmap.Width := AlphaView.Bitmap.Height;
|
||||
ImgView32.Bitmap.Height := AlphaView.Bitmap.Width;
|
||||
|
||||
for x := 0 to AlphaView.Bitmap.Width - 1 do
|
||||
for y := 0 to AlphaView.Bitmap.Height - 1 do
|
||||
begin
|
||||
C := AlphaView.Bitmap.Pixel[x, y];
|
||||
|
||||
DestX := (ImgView32.Bitmap.Width - 1) - Y;
|
||||
DestY := X;
|
||||
|
||||
ImgView32.Bitmap.Pixels[DestX, DestY] := C;
|
||||
end;
|
||||
|
||||
ImgView32.EndUpdate;
|
||||
ImgView32.Refresh;
|
||||
end;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.RotateAntiClockwiseItemClick(Sender: TObject);
|
||||
var
|
||||
x : integer;
|
||||
y : integer;
|
||||
DestX : integer;
|
||||
DestY : integer;
|
||||
C : TColor32;
|
||||
begin
|
||||
AlphaView.Bitmap.Assign(ImgView32.Bitmap);
|
||||
|
||||
ImgView32.BeginUpdate;
|
||||
ImgView32.Bitmap.Width := AlphaView.Bitmap.Height;
|
||||
ImgView32.Bitmap.Height := AlphaView.Bitmap.Width;
|
||||
|
||||
for x := 0 to AlphaView.Bitmap.Width - 1 do
|
||||
for y := 0 to AlphaView.Bitmap.Height - 1 do
|
||||
begin
|
||||
C := AlphaView.Bitmap.Pixel[x, y];
|
||||
|
||||
DestX := Y;
|
||||
DestY := (ImgView32.Bitmap.Height - 1) -X;
|
||||
|
||||
ImgView32.Bitmap.Pixels[DestX, DestY] := C;
|
||||
end;
|
||||
|
||||
ImgView32.EndUpdate;
|
||||
ImgView32.Refresh;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.ShowWithAlphaItemClick(Sender: TObject);
|
||||
begin
|
||||
if ShowWithAlphaItem.Checked then
|
||||
ImgView32.Bitmap.DrawMode := dmOpaque
|
||||
else
|
||||
ImgView32.Bitmap.DrawMode := dmBlend;
|
||||
ShowWithAlphaItem.Checked := not ShowWithAlphaItem.Checked;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.FlipHorizontalItemClick(Sender: TObject);
|
||||
var
|
||||
x : integer;
|
||||
y : integer;
|
||||
DestX : integer;
|
||||
DestY : integer;
|
||||
C : TColor32;
|
||||
begin
|
||||
AlphaView.Bitmap.Assign(ImgView32.Bitmap);
|
||||
|
||||
ImgView32.BeginUpdate;
|
||||
ImgView32.Bitmap.Width := AlphaView.Bitmap.Width;
|
||||
ImgView32.Bitmap.Height := AlphaView.Bitmap.Height;
|
||||
|
||||
for x := 0 to AlphaView.Bitmap.Width - 1 do
|
||||
for y := 0 to AlphaView.Bitmap.Height - 1 do
|
||||
begin
|
||||
C := AlphaView.Bitmap.Pixel[x, y];
|
||||
|
||||
DestX := (ImgView32.Bitmap.Width - 1) -X;
|
||||
DestY := Y;
|
||||
|
||||
ImgView32.Bitmap.Pixels[DestX, DestY] := C;
|
||||
end;
|
||||
|
||||
ImgView32.EndUpdate;
|
||||
ImgView32.Refresh;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.FilpVerticalItemClick(Sender: TObject);
|
||||
var
|
||||
x : integer;
|
||||
y : integer;
|
||||
DestX : integer;
|
||||
DestY : integer;
|
||||
C : TColor32;
|
||||
begin
|
||||
AlphaView.Bitmap.Assign(ImgView32.Bitmap);
|
||||
|
||||
ImgView32.BeginUpdate;
|
||||
ImgView32.Bitmap.Width := AlphaView.Bitmap.Width;
|
||||
ImgView32.Bitmap.Height := AlphaView.Bitmap.Height;
|
||||
|
||||
for x := 0 to AlphaView.Bitmap.Width - 1 do
|
||||
for y := 0 to AlphaView.Bitmap.Height - 1 do
|
||||
begin
|
||||
C := AlphaView.Bitmap.Pixel[x, y];
|
||||
|
||||
DestX := X;
|
||||
DestY := (ImgView32.Bitmap.Height - 1) - Y;
|
||||
|
||||
ImgView32.Bitmap.Pixels[DestX, DestY] := C;
|
||||
end;
|
||||
|
||||
ImgView32.EndUpdate;
|
||||
ImgView32.Refresh;
|
||||
end;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.FilterTimerTimer(Sender: TObject);
|
||||
var
|
||||
Resampler: TKernelResampler;
|
||||
begin
|
||||
FilterTimer.Enabled := False;
|
||||
Resampler := TKernelResampler.Create(ImgView32.Bitmap);
|
||||
Resampler.Kernel := TSplineKernel.Create;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.ImgView32Scroll(Sender: TObject);
|
||||
begin
|
||||
FilterTimer.Enabled := False;
|
||||
if not (ImgView32.Bitmap.Resampler is TNearestResampler) then
|
||||
TNearestResampler.Create(ImgView32.Bitmap);
|
||||
FilterTimer.Enabled := True;
|
||||
end;
|
||||
// -----------------------------------------------------------------------------
|
||||
procedure TMainForm.OpenImageItemClick(Sender: TObject);
|
||||
begin
|
||||
if OpenDialog.Execute then
|
||||
begin
|
||||
try
|
||||
Screen.Cursor := crHourGlass;
|
||||
LoadImage(OpenDialog.FileName);
|
||||
finally
|
||||
Screen.Cursor := crDefault;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
@ -0,0 +1,8 @@
|
||||
This is a simple image viewing application that uses the FreeImage library to display images in many different formats.
|
||||
|
||||
The app displays the image whose name is passed in as a command line argument.
|
||||
|
||||
|
||||
To compile the app you will also need the Graphics32 library available from www.g32.org. It has been tested with version 1.5.1 of Graphics32.
|
||||
|
||||
SJB.
|
After Width: | Height: | Size: 63 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue