/////////////////////////////////////////////////////////////////////////////
-// Name: image.cpp
+// Name: src/common/image.cpp
// Purpose: wxImage
// Author: Robert Roebling
// RCS-ID: $Id$
return false;
}
- return handler->LoadFile(this, stream, true/*verbose*/, index);
+ if (!handler->CanRead(stream))
+ {
+ wxLogError(_("Image file is not of type %d."), type);
+ return false;
+ }
+ else
+ return handler->LoadFile(this, stream, true/*verbose*/, index);
}
bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype, int index )
return false;
}
- return handler->LoadFile( this, stream, true/*verbose*/, index );
+ if (!handler->CanRead(stream))
+ {
+ wxLogError(_("Image file is not of type %s."), (const wxChar*) mimetype);
+ return false;
+ }
+ else
+ return handler->LoadFile( this, stream, true/*verbose*/, index );
}
bool wxImage::SaveFile( wxOutputStream& stream, int type ) const
const double value = maximumRGB;
- double hue, saturation;
+ double hue = 0.0, saturation;
const double deltaRGB = maximumRGB - minimumRGB;
if ( wxIsNullDouble(deltaRGB) )
{
case BLUE:
hue = 4.0 + (red - green) / deltaRGB;
break;
+
+ default:
+ wxFAIL_MSG(wxT("hue not specified"));
+ break;
}
hue /= 6.0;
wxRealPoint p3 = rotated_point (GetWidth(), 0, cos_angle, sin_angle, p0);
wxRealPoint p4 = rotated_point (GetWidth(), GetHeight(), cos_angle, sin_angle, p0);
- int x1 = (int) floor (wxMin (wxMin(p1.x, p2.x), wxMin(p3.x, p4.x)));
- int y1 = (int) floor (wxMin (wxMin(p1.y, p2.y), wxMin(p3.y, p4.y)));
- int x2 = (int) ceil (wxMax (wxMax(p1.x, p2.x), wxMax(p3.x, p4.x)));
- int y2 = (int) ceil (wxMax (wxMax(p1.y, p2.y), wxMax(p3.y, p4.y)));
+ int x1a = (int) floor (wxMin (wxMin(p1.x, p2.x), wxMin(p3.x, p4.x)));
+ int y1a = (int) floor (wxMin (wxMin(p1.y, p2.y), wxMin(p3.y, p4.y)));
+ int x2a = (int) ceil (wxMax (wxMax(p1.x, p2.x), wxMax(p3.x, p4.x)));
+ int y2a = (int) ceil (wxMax (wxMax(p1.y, p2.y), wxMax(p3.y, p4.y)));
// Create rotated image
- wxImage rotated (x2 - x1 + 1, y2 - y1 + 1, false);
+ wxImage rotated (x2a - x1a + 1, y2a - y1a + 1, false);
// With alpha channel
if (has_alpha)
rotated.SetAlpha();
if (offset_after_rotation != NULL)
{
- *offset_after_rotation = wxPoint (x1, y1);
+ *offset_after_rotation = wxPoint (x1a, y1a);
}
// GRG: The rotated (destination) image is always accessed
{
for (x = 0; x < rotated.GetWidth(); x++)
{
- wxRealPoint src = rotated_point (x + x1, y + y1, cos_angle, -sin_angle, p0);
+ wxRealPoint src = rotated_point (x + x1a, y + y1a, cos_angle, -sin_angle, p0);
if (-0.25 < src.x && src.x < GetWidth() - 0.75 &&
-0.25 < src.y && src.y < GetHeight() - 0.75)
// interpolate using the 4 enclosing grid-points. Those
// points can be obtained using floor and ceiling of the
// exact coordinates of the point
- // C.M. 2000-02-17: when the point is near the border, special care is required.
-
int x1, y1, x2, y2;
if (0 < src.x && src.x < GetWidth() - 1)
*(dst++) = *p;
if (has_alpha)
- {
- unsigned char *p = alpha[y1] + x1;
- *(alpha_dst++) = *p;
- }
+ *(alpha_dst++) = *(alpha[y1] + x1);
}
else if (d2 < gs_Epsilon)
{
*(dst++) = *p;
if (has_alpha)
- {
- unsigned char *p = alpha[y1] + x2;
- *(alpha_dst++) = *p;
- }
+ *(alpha_dst++) = *(alpha[y1] + x2);
}
else if (d3 < gs_Epsilon)
{
*(dst++) = *p;
if (has_alpha)
- {
- unsigned char *p = alpha[y2] + x2;
- *(alpha_dst++) = *p;
- }
+ *(alpha_dst++) = *(alpha[y2] + x2);
}
else if (d4 < gs_Epsilon)
{
*(dst++) = *p;
if (has_alpha)
- {
- unsigned char *p = alpha[y2] + x1;
- *(alpha_dst++) = *p;
- }
+ *(alpha_dst++) = *(alpha[y2] + x1);
}
else
{
if (has_alpha)
{
- unsigned char *v1 = alpha[y1] + (x1);
- unsigned char *v2 = alpha[y1] + (x2);
- unsigned char *v3 = alpha[y2] + (x2);
- unsigned char *v4 = alpha[y2] + (x1);
+ v1 = alpha[y1] + (x1);
+ v2 = alpha[y1] + (x2);
+ v3 = alpha[y2] + (x2);
+ v4 = alpha[y2] + (x1);
*(alpha_dst++) = (unsigned char)
( (w1 * *v1 + w2 * *v2 +
{
for (x = 0; x < rotated.GetWidth(); x++)
{
- wxRealPoint src = rotated_point (x + x1, y + y1, cos_angle, -sin_angle, p0);
+ wxRealPoint src = rotated_point (x + x1a, y + y1a, cos_angle, -sin_angle, p0);
const int xs = wxCint (src.x); // wxCint rounds to the
const int ys = wxCint (src.y); // closest integer
*(dst++) = *p;
if (has_alpha)
- {
- unsigned char *p = alpha[ys] + (xs);
- *(alpha_dst++) = *p;
- }
+ *(alpha_dst++) = *(alpha[ys] + (xs));
}
else
{