Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Youssefi
otb
Commits
6415132d
Commit
6415132d
authored
13 years ago
by
Julien Malik
Browse files
Options
Downloads
Patches
Plain Diff
ENH: handle CHAR, UCHAR, and SHORT type in JPEG2000ImageIO
parent
73ad2a6c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/IO/otbJPEG2000ImageIO.cxx
+66
-15
66 additions, 15 deletions
Code/IO/otbJPEG2000ImageIO.cxx
with
66 additions
and
15 deletions
Code/IO/otbJPEG2000ImageIO.cxx
+
66
−
15
View file @
6415132d
...
...
@@ -293,7 +293,7 @@ int JPEG2000ReaderInternal::Initialize()
return
0
;
}
for
(
int
itComp
=
0
;
itComp
<
this
->
m_NbOfComponent
;
itComp
++
)
for
(
unsigned
int
itComp
=
0
;
itComp
<
this
->
m_NbOfComponent
;
itComp
++
)
{
this
->
m_Precision
[
itComp
]
=
this
->
m_Image
->
comps
[
itComp
].
prec
;
}
...
...
@@ -304,7 +304,7 @@ int JPEG2000ReaderInternal::Initialize()
this
->
Clean
();
return
0
;
}
for
(
int
itComp
=
0
;
itComp
<
this
->
m_NbOfComponent
;
itComp
++
)
for
(
unsigned
int
itComp
=
0
;
itComp
<
this
->
m_NbOfComponent
;
itComp
++
)
{
this
->
m_Signed
[
itComp
]
=
this
->
m_Image
->
comps
[
itComp
].
sgnd
;
}
...
...
@@ -316,7 +316,7 @@ int JPEG2000ReaderInternal::Initialize()
return
0
;
}
for
(
int
itComp
=
0
;
itComp
<
this
->
m_NbOfComponent
;
itComp
++
)
for
(
unsigned
int
itComp
=
0
;
itComp
<
this
->
m_NbOfComponent
;
itComp
++
)
{
this
->
m_XResolution
[
itComp
]
=
this
->
m_Image
->
comps
[
itComp
].
dx
;
}
...
...
@@ -328,7 +328,7 @@ int JPEG2000ReaderInternal::Initialize()
return
0
;
}
for
(
int
itComp
=
0
;
itComp
<
this
->
m_NbOfComponent
;
itComp
++
)
for
(
unsigned
int
itComp
=
0
;
itComp
<
this
->
m_NbOfComponent
;
itComp
++
)
{
this
->
m_YResolution
[
itComp
]
=
this
->
m_Image
->
comps
[
itComp
].
dy
;
}
...
...
@@ -352,7 +352,7 @@ int JPEG2000ReaderInternal::CanRead()
{
// We manage only JPEG2000 file with characteristics which are equal between components
for
(
int
itComp
=
0
;
itComp
<
this
->
m_NbOfComponent
-
1
;
itComp
++
)
for
(
unsigned
int
itComp
=
0
;
itComp
<
this
->
m_NbOfComponent
-
1
;
itComp
++
)
{
if
(
(
this
->
m_Precision
[
itComp
]
!=
this
->
m_Precision
[
itComp
+
1
])
&&
(
this
->
m_Signed
[
itComp
]
!=
this
->
m_Signed
[
itComp
+
1
])
&&
...
...
@@ -489,36 +489,87 @@ void JPEG2000ImageIO::Read(void* buffer)
this
->
ComputeOffsets
(
lWidthSrc
,
lHeightDest
,
lWidthDest
,
lStartOffsetPxlDest
,
lStartOffsetPxlSrc
);
std
::
cout
<<
"Extraction tuile "
<<
*
itTile
<<
std
::
endl
;
switch
(
this
->
GetComponentType
())
{
// case CHAR:
// case UCHAR:
// case SHORT:
case
USHORT
:
case
CHAR
:
{
unsigned
short
*
p
=
static_cast
<
unsigned
short
*>
(
buffer
);
char
*
p
=
static_cast
<
char
*>
(
buffer
);
for
(
unsigned
int
j
=
0
;
j
<
lHeightDest
;
++
j
)
{
char
*
current_dst_line
=
p
+
(
lStartOffsetPxlDest
+
j
*
lNbColumns
)
*
this
->
m_NumberOfComponents
;
/* Move the output buffer to the first place where we will write*/
for
(
unsigned
int
k
=
0
;
k
<
lWidthDest
;
++
k
)
{
for
(
unsigned
int
itComp
=
0
;
itComp
<
this
->
m_NumberOfComponents
;
itComp
++
)
{
OPJ_INT32
*
data
=
m_InternalReader
->
GetImage
()
->
comps
[
itComp
].
data
;
*
(
current_dst_line
++
)
=
static_cast
<
char
>
(
data
[
lStartOffsetPxlSrc
+
k
+
j
*
lWidthSrc
]);
}
}
}
}
break
;
case
UCHAR
:
{
unsigned
char
*
p
=
static_cast
<
unsigned
char
*>
(
buffer
);
for
(
unsigned
int
j
=
0
;
j
<
lHeightDest
;
++
j
)
{
unsigned
char
*
current_dst_line
=
p
+
(
lStartOffsetPxlDest
+
j
*
lNbColumns
)
*
this
->
m_NumberOfComponents
;
for
(
unsigned
int
k
=
0
;
k
<
lWidthDest
;
++
k
)
{
for
(
unsigned
int
itComp
=
0
;
itComp
<
this
->
m_NumberOfComponents
;
itComp
++
)
{
OPJ_INT32
*
data
=
m_InternalReader
->
GetImage
()
->
comps
[
itComp
].
data
;
unsigned
char
component_val
=
data
[
lStartOffsetPxlSrc
+
k
+
j
*
lWidthSrc
]
&
0xff
;
*
(
current_dst_line
++
)
=
static_cast
<
unsigned
char
>
(
component_val
);
}
}
}
}
break
;
case
SHORT
:
{
short
*
p
=
static_cast
<
short
*>
(
buffer
);
for
(
unsigned
int
j
=
0
;
j
<
lHeightDest
;
++
j
)
{
unsigned
short
*
current_dst_line
=
p
+
(
lStartOffsetPxlDest
+
j
*
lNbColumns
)
*
this
->
m_NumberOfComponents
;
short
*
current_dst_line
=
p
+
(
lStartOffsetPxlDest
+
j
*
lNbColumns
)
*
this
->
m_NumberOfComponents
;
for
(
unsigned
int
k
=
0
;
k
<
lWidthDest
;
++
k
)
{
for
(
unsigned
int
itComp
=
0
;
itComp
<
this
->
m_NumberOfComponents
;
itComp
++
)
{
OPJ_INT32
*
data
=
m_InternalReader
->
GetImage
()
->
comps
[
itComp
].
data
;
*
(
current_dst_line
++
)
=
static_cast
<
short
>
(
data
[
lStartOffsetPxlSrc
+
k
+
j
*
lWidthSrc
]);
}
}
}
}
break
;
case
USHORT
:
{
unsigned
short
*
p
=
static_cast
<
unsigned
short
*>
(
buffer
);
for
(
unsigned
int
j
=
0
;
j
<
lHeightDest
;
++
j
)
{
unsigned
short
*
current_dst_line
=
p
+
(
lStartOffsetPxlDest
+
j
*
lNbColumns
)
*
this
->
m_NumberOfComponents
;
for
(
unsigned
int
k
=
0
;
k
<
lWidthDest
;
++
k
)
{
for
(
unsigned
int
itComp
=
0
;
itComp
<
this
->
m_NumberOfComponents
;
itComp
++
)
{
OPJ_INT32
*
data
=
m_InternalReader
->
GetImage
()
->
comps
[
itComp
].
data
;
*
(
current_dst_line
++
)
=
static_cast
<
unsigned
short
>
(
data
[
lStartOffsetPxlSrc
+
k
+
j
*
lWidthSrc
]
&
0xffff
);
}
}
}
}
break
;
// case INT:
// case UINT:
case
INT
:
case
UINT
:
default
:
itkGenericExceptionMacro
(
<<
"This data type is not handled"
);
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment