Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
d722bb78
Commit
d722bb78
authored
Mar 04, 2014
by
roland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for ihaskell-juicypixels
parent
3da50156
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
210 additions
and
0 deletions
+210
-0
Juicypixels.hs
ihaskell-juicypixels/IHaskell/Display/Juicypixels.hs
+70
-0
LICENSE
ihaskell-juicypixels/LICENSE
+20
-0
Setup.hs
ihaskell-juicypixels/Setup.hs
+2
-0
ihaskell-juicypixels.cabal
ihaskell-juicypixels/ihaskell-juicypixels.cabal
+76
-0
test.ipynb
ihaskell-juicypixels/test.ipynb
+42
-0
No files found.
ihaskell-juicypixels/IHaskell/Display/Juicypixels.hs
0 → 100644
View file @
d722bb78
{-# LANGUAGE NoImplicitPrelude, TypeSynonymInstances, FlexibleInstances #-}
module
IHaskell.Display.Juicypixels
(
module
IHaskell
.
Display
,
module
Codec
.
Picture
)
where
import
Codec.Picture
import
ClassyPrelude
import
IHaskell.Display
import
System.Directory
import
System.IO.Unsafe
-- instances
instance
IHaskellDisplay
DynamicImage
where
display
=
displayImageAsJpg
instance
IHaskellDisplay
(
Image
Pixel8
)
where
display
=
displayImageAsJpg
.
ImageY8
instance
IHaskellDisplay
(
Image
Pixel16
)
where
display
=
displayImageAsJpg
.
ImageY16
instance
IHaskellDisplay
(
Image
PixelF
)
where
display
=
displayImageAsJpg
.
ImageYF
instance
IHaskellDisplay
(
Image
PixelYA8
)
where
display
=
displayImageAsJpg
.
ImageYA8
instance
IHaskellDisplay
(
Image
PixelYA16
)
where
display
=
displayImageAsJpg
.
ImageYA16
instance
IHaskellDisplay
(
Image
PixelRGB8
)
where
display
=
displayImageAsJpg
.
ImageRGB8
instance
IHaskellDisplay
(
Image
PixelRGB16
)
where
display
=
displayImageAsJpg
.
ImageRGB16
instance
IHaskellDisplay
(
Image
PixelRGBF
)
where
display
=
displayImageAsJpg
.
ImageRGBF
instance
IHaskellDisplay
(
Image
PixelRGBA8
)
where
display
=
displayImageAsJpg
.
ImageRGBA8
instance
IHaskellDisplay
(
Image
PixelRGBA16
)
where
display
=
displayImageAsJpg
.
ImageRGBA16
instance
IHaskellDisplay
(
Image
PixelYCbCr8
)
where
display
=
displayImageAsJpg
.
ImageYCbCr8
instance
IHaskellDisplay
(
Image
PixelCMYK8
)
where
display
=
displayImageAsJpg
.
ImageCMYK8
instance
IHaskellDisplay
(
Image
PixelCMYK16
)
where
display
=
displayImageAsJpg
.
ImageCMYK16
-- main rendering function
displayImageAsJpg
::
DynamicImage
->
IO
Display
displayImageAsJpg
renderable
=
do
-- Switch to a temporary directory so that any files we create aren't
-- visible. On Unix, this is usually /tmp.
try
(
getTemporaryDirectory
>>=
setCurrentDirectory
)
::
IO
(
Either
SomeException
()
)
let
filename
=
".ihaskell.juicypixels.jpg"
-- Write the image
saveJpgImage
95
filename
renderable
-- Convert to base64.
imgData
<-
readFile
$
fpFromString
filename
return
$
Display
[
jpg
(
imWidth
renderable
)
(
imHeight
renderable
)
$
base64
imgData
]
-- The type DynamicImage does not have a function to extract width and height
imWidth
::
DynamicImage
->
Int
imWidth
img
=
w
where
(
w
,
h
)
=
imWidthHeight
img
imHeight
::
DynamicImage
->
Int
imHeight
img
=
h
where
(
w
,
h
)
=
imWidthHeight
img
-- Helper functions to pattern match on the DynamicImage Constructors
imWidthHeight
::
DynamicImage
->
(
Int
,
Int
)
imWidthHeight
(
ImageY8
im
)
=
imWH
im
imWidthHeight
(
ImageY16
im
)
=
imWH
im
imWidthHeight
(
ImageYF
im
)
=
imWH
im
imWidthHeight
(
ImageYA8
im
)
=
imWH
im
imWidthHeight
(
ImageYA16
im
)
=
imWH
im
imWidthHeight
(
ImageRGB8
im
)
=
imWH
im
imWidthHeight
(
ImageRGB16
im
)
=
imWH
im
imWidthHeight
(
ImageRGBF
im
)
=
imWH
im
imWidthHeight
(
ImageRGBA8
im
)
=
imWH
im
imWidthHeight
(
ImageRGBA16
im
)
=
imWH
im
imWidthHeight
(
ImageYCbCr8
im
)
=
imWH
im
imWidthHeight
(
ImageCMYK8
im
)
=
imWH
im
imWidthHeight
(
ImageCMYK16
im
)
=
imWH
im
imWH
::
(
Image
a
)
->
(
Int
,
Int
)
imWH
im
=
(
imageWidth
im
,
imageHeight
im
)
ihaskell-juicypixels/LICENSE
0 → 100644
View file @
d722bb78
The MIT License (MIT)
Copyright (c) 2013 Roland Senn
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.
ihaskell-juicypixels/Setup.hs
0 → 100644
View file @
d722bb78
import
Distribution.Simple
main
=
defaultMain
ihaskell-juicypixels/ihaskell-juicypixels.cabal
0 → 100644
View file @
d722bb78
-- The name of the package.
name: ihaskell-juicypixels
-- The package version. See the Haskell package versioning policy (PVP)
-- for standards guiding when and how versions should be incremented.
-- http://www.haskell.org/haskellwiki/Package_versioning_policy
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
version: 0.1.0.0
-- A short (one-line) description of the package.
synopsis: IHaskell - IHaskellDisplay instances of the image types of the JuicyPixels package.
-- A longer description of the package.
description: IHaskellDisplay instances of the image types of the JuicyPixels package. They are displayed as .JPG images.
DynamicImages and Images of types PixelRGBA16, PixelRGBA8, PixelRGB16, PixelRGB8,
PixelYA16, PixelYA8, Pixel16, Pixel8, PixelCMYK16, PixelCMYK8, PixelF, Pixel32
are supported.
The module IHaskell.Juicypixels re-exports the modules IHaskell.Display and Codec.Picture.
-- URL for the project homepage or repository.
homepage: http://www.github.com/gibiansky/ihaskell
-- The license under which the package is released.
license: MIT
-- The file containing the license text.
license-file: LICENSE
-- The package author(s).
author: Roland Senn
-- An email address to which users can send suggestions, bug reports, and
-- patches.
maintainer: rsx@bluewin.ch
-- A copyright notice.
-- copyright:
category: Development
build-type: Simple
-- Extra files to be distributed with the package, such as examples or a
-- README.
-- extra-source-files:
-- Constraint on the version of Cabal needed to build this package.
cabal-version: >=1.16
library
-- Modules exported by the library.
exposed-modules: IHaskell.Display.Juicypixels
-- Modules included in this library but not exported.
-- other-modules:
-- Language extensions.
default-extensions: DoAndIfThenElse
OverloadedStrings
-- Other library packages from which modules are imported.
build-depends: base ==4.6.*,
classy-prelude >=0.6,
bytestring,
directory,
JuicyPixels >= 3.1.3,
ihaskell >= 0.3
-- Directories containing source files.
-- hs-source-dirs:
-- Base language which the package is written in.
default-language: Haskell2010
ihaskell-juicypixels/test.ipynb
0 → 100644
View file @
d722bb78
{
"metadata": {
"language": "haskell",
"name": "",
"signature": "sha256:b9b36c162e37a16b252cd1f06e4c2991e0a80710e7fc184be82dd6b18e6dcf01"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"{-# LANGUAGE NoImplicitPrelude, TypeSynonymInstances, FlexibleInstances #-}\n",
"\n",
"import IHaskell.Display.Juicypixels\n",
" \n",
"myImage = generateImage pixelRenderer 250 300\n",
" where pixelRenderer x y = PixelRGB8 (fromIntegral x) (fromIntegral y) 128\n",
" \n",
"myImage "
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment