static const QuantumType z2qtype[4] = {GrayQuantum, BlueQuantum, GreenQuantum, RedQuantum};
-
static void InsertComplexDoubleRow(Image *image,double *p,int y,double MinVal,
double MaxVal,ExceptionInfo *exception)
{
-
double f;
int x;
register Quantum *q;
- if (MinVal == 0)
+ if (MinVal >= 0)
MinVal = -1;
- if (MaxVal == 0)
+ if (MaxVal <= 0)
MaxVal = 1;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
for (x = 0; x < (ssize_t) image->columns; x++)
{
if (*p > 0)
- {
- f = (*p / MaxVal) * (QuantumRange-GetPixelRed(image,q));
- if (f + GetPixelRed(image,q) > QuantumRange)
- SetPixelRed(image,QuantumRange,q);
- else
- SetPixelRed(image,GetPixelRed(image,q)+(int) f,q);
- if ((int) f / 2.0 > GetPixelGreen(image,q))
- {
- SetPixelGreen(image,0,q);
- SetPixelBlue(image,0,q);
- }
- else
- {
- SetPixelBlue(image,GetPixelBlue(image,q)-(int) (f/2.0),q);
- SetPixelGreen(image,GetPixelBlue(image,q),q);
- }
- }
+ {
+ f=(*p/MaxVal)*(Quantum) (QuantumRange-GetPixelRed(image,q));
+ if ((f+GetPixelRed(image,q)) >= QuantumRange)
+ SetPixelRed(image,QuantumRange,q);
+ else
+ SetPixelRed(image,GetPixelRed(image,q)+ClampToQuantum(f),q);
+ f=GetPixelGreen(image,q)-f/2.0;
+ if (f <= 0.0)
+ {
+ SetPixelGreen(image,0,q);
+ SetPixelBlue(image,0,q);
+ }
+ else
+ {
+ SetPixelBlue(image,ClampToQuantum(f),q);
+ SetPixelGreen(image,ClampToQuantum(f),q);
+ }
+ }
if (*p < 0)
- {
- f = (*p / MinVal) * (QuantumRange-GetPixelBlue(image,q));
- if (f+GetPixelBlue(image,q) > QuantumRange)
- SetPixelBlue(image,QuantumRange,q);
- else
- SetPixelBlue(image,GetPixelBlue(image,q)+(int) f,q);
- if ((int) f / 2.0 > GetPixelGreen(image,q))
- {
- SetPixelRed(image,0,q);
- SetPixelGreen(image,0,q);
- }
- else
- {
- SetPixelRed(image,GetPixelRed(image,q)-(int) (f/2.0),q);
- SetPixelGreen(image,GetPixelRed(image,q),q);
- }
- }
+ {
+ f=(*p/MinVal)*(Quantum) (QuantumRange-GetPixelBlue(image,q));
+ if ((f+GetPixelBlue(image,q)) >= QuantumRange)
+ SetPixelBlue(image,QuantumRange,q);
+ else
+ SetPixelBlue(image,GetPixelBlue(image,q)+ClampToQuantum(f),q);
+ f=GetPixelGreen(image,q)-f/2.0;
+ if (f <= 0.0)
+ {
+ SetPixelRed(image,0,q);
+ SetPixelGreen(image,0,q);
+ }
+ else
+ {
+ SetPixelRed(image,ClampToQuantum(f),q);
+ SetPixelGreen(image,ClampToQuantum(f),q);
+ }
+ }
p++;
- q+=GetPixelChannels(image);
+ q++;
}
if (!SyncAuthenticPixels(image,exception))
return;
return;
}
-
static void InsertComplexFloatRow(Image *image,float *p,int y,double MinVal,
double MaxVal,ExceptionInfo *exception)
{
int x;
register Quantum *q;
- if (MinVal == 0)
+ if (MinVal >= 0)
MinVal = -1;
- if (MaxVal == 0)
+ if (MaxVal <= 0)
MaxVal = 1;
q = QueueAuthenticPixels(image, 0, y, image->columns, 1,exception);
for (x = 0; x < (ssize_t) image->columns; x++)
{
if (*p > 0)
- {
- f = (*p / MaxVal) * (QuantumRange-GetPixelRed(image,q));
- if (f+GetPixelRed(image,q) > QuantumRange)
- SetPixelRed(image,QuantumRange,q);
- else
- SetPixelRed(image,GetPixelRed(image,q)+(int) f,q);
- if ((int) f / 2.0 > GetPixelGreen(image,q))
- {
- SetPixelGreen(image,0,q);
- SetPixelBlue(image,0,q);
- }
- else
- {
- SetPixelBlue(image,GetPixelBlue(image,q)-(int) (f/2.0),q);
- SetPixelGreen(image,GetPixelBlue(image,q),q);
- }
- }
+ {
+ f=(*p/MaxVal)*(Quantum) (QuantumRange-GetPixelRed(image,q));
+ if ((f+GetPixelRed(image,q)) < QuantumRange)
+ SetPixelRed(image,GetPixelRed(image,q)+ClampToQuantum(f),q);
+ else
+ SetPixelRed(image,QuantumRange,q);
+ f/=2.0;
+ if (f < GetPixelGreen(image,q))
+ {
+ SetPixelBlue(image,GetPixelBlue(image,q)-ClampToQuantum(f),q);
+ SetPixelGreen(image,GetPixelBlue(image,q),q);
+ }
+ else
+ {
+ SetPixelGreen(image,0,q);
+ SetPixelBlue(image,0,q);
+ }
+ }
if (*p < 0)
- {
- f = (*p / MaxVal) * (QuantumRange - GetPixelBlue(image,q));
- if (f + GetPixelBlue(image,q) > QuantumRange)
- SetPixelBlue(image,QuantumRange,q);
- else
- SetPixelBlue(image,GetPixelBlue(image,q)+
- (int) f,q);
- if ((int) f / 2.0 > GetPixelGreen(image,q))
- {
- SetPixelGreen(image,0,q);
- SetPixelRed(image,0,q);
- }
- else
- {
- SetPixelRed(image,GetPixelRed(image,q)-(int) (f/2.0),q);
- SetPixelGreen(image,GetPixelRed(image,q),q);
- }
- }
+ {
+ f=(*p/MaxVal)*(Quantum) (QuantumRange-GetPixelBlue(image,q));
+ if ((f > 0) && ((f+GetPixelBlue(image,q)) < QuantumRange))
+ SetPixelBlue(image,GetPixelBlue(image,q)+ClampToQuantum(f),q);
+ else
+ SetPixelBlue(image,QuantumRange,q);
+ f/=2.0;
+ if (f < GetPixelGreen(image,q))
+ {
+ SetPixelRed(image,GetPixelRed(image,q)-ClampToQuantum(f),q);
+ SetPixelGreen(image,GetPixelRed(image,q),q);
+ }
+ else
+ {
+ SetPixelGreen(image,0,q);
+ SetPixelRed(image,0,q);
+ }
+ }
p++;
q++;
}
unsigned int
depth;
-
quantum_info=(QuantumInfo *) NULL;
(void) SeekBlob(image,0,SEEK_SET);
+ status=MagickTrue;
while (EOFBlob(image) == MagickFalse)
{
/*
MATLAB_HDR.StructureClass != mxINT64_CLASS &&
MATLAB_HDR.StructureClass != mxUINT64_CLASS) /* uint64 + uint64 3D */
{
- if (image2 != (Image*) NULL)
+ if ((image2 != (Image*) NULL) && (image2 != image))
{
CloseBlob(image2);
DeleteImageFromList(&image2);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
"MATLAB_HDR.CellType: %.20g",(double) CellType);
- (void) ReadBlob(image2, 4, (unsigned char *) &size); /* data size */
+ /* data size */
+ if (ReadBlob(image2, 4, (unsigned char *) &size) != 4)
+ goto MATLAB_KO;
NEXT_FRAME:
switch (CellType)