mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-13 00:44:34 +00:00
Fix several warnings in MSVC, clang, and gcc
This commit is contained in:
parent
5c1f2a55a5
commit
b23194dfae
@ -119,7 +119,7 @@ Color Color::fromString(const std::string& str)
|
||||
if (str.find("rgb{") == 0 ||
|
||||
str.find("hsv{") == 0) {
|
||||
int c = 0, table[3] = { 0, 0, 0 };
|
||||
int i = 4, j;
|
||||
std::string::size_type i = 4, j;
|
||||
|
||||
while ((j = str.find_first_of(",}", i)) != std::string::npos) {
|
||||
std::string element = str.substr(i, j - i);
|
||||
|
@ -354,7 +354,7 @@ void PaletteEntryEditor::setColor(const app::Color& color)
|
||||
else if (j-i+1 == i2-i) {
|
||||
m_entryLabel.setTextf(" Range: %d-%d", i, j);
|
||||
}
|
||||
else if (i == entries.size()) {
|
||||
else if (i == int(entries.size())) {
|
||||
m_entryLabel.setText(" No Entry");
|
||||
}
|
||||
else {
|
||||
|
@ -47,7 +47,6 @@ bool RemoveFrameTagCommand::onEnabled(Context* context)
|
||||
void RemoveFrameTagCommand::onExecute(Context* context)
|
||||
{
|
||||
ContextWriter writer(context);
|
||||
Document* document(writer.document());
|
||||
Sprite* sprite(writer.sprite());
|
||||
frame_t frame = writer.frame();
|
||||
|
||||
|
@ -137,7 +137,7 @@ void SpritePropertiesCommand::onExecute(Context* context)
|
||||
// If the transparent color index has changed, we update the
|
||||
// property in the sprite.
|
||||
int index = color_button->getColor().getIndex();
|
||||
if (index != sprite->transparentColor()) {
|
||||
if (color_t(index) != sprite->transparentColor()) {
|
||||
Transaction transaction(writer.context(), "Set Transparent Color");
|
||||
DocumentApi api = writer.document()->getApi(transaction);
|
||||
api.setSpriteTransparentColor(sprite, index);
|
||||
|
@ -75,8 +75,10 @@ protected:
|
||||
DocumentApi api = m_writer.document()->getApi(transaction);
|
||||
|
||||
int cels_count = 0;
|
||||
for (Cel* cel : m_sprite->uniqueCels())
|
||||
for (Cel* cel : m_sprite->uniqueCels()) { // TODO add size() member function to CelsRange
|
||||
(void)cel;
|
||||
++cels_count;
|
||||
}
|
||||
|
||||
// For each cel...
|
||||
int progress = 0;
|
||||
|
@ -56,7 +56,7 @@ void ConvolutionMatrixStock::reloadStock()
|
||||
"convmatr.gen",
|
||||
"convmatr.def", NULL };
|
||||
char *s, buf[256], leavings[4096];
|
||||
int i, c, x, y, w, h, div, bias;
|
||||
int i, x, y, w, h, div, bias;
|
||||
SharedPtr<ConvolutionMatrix> matrix;
|
||||
std::string name;
|
||||
|
||||
@ -109,7 +109,6 @@ void ConvolutionMatrixStock::reloadStock()
|
||||
if (*buf != '{')
|
||||
break;
|
||||
|
||||
c = 0;
|
||||
div = 0;
|
||||
for (y=0; y<h; ++y) {
|
||||
for (x=0; x<w; ++x) {
|
||||
|
@ -302,7 +302,7 @@ void DocumentExporter::captureSamples(Samples& samples)
|
||||
renderSample(sample, sampleRender);
|
||||
|
||||
gfx::Rect frameBounds;
|
||||
doc::color_t refColor;
|
||||
doc::color_t refColor = 0;
|
||||
|
||||
if (m_trimCels)
|
||||
refColor = get_pixel(sampleRender, 0, 0);
|
||||
|
@ -162,8 +162,8 @@ static DocumentRange drop_range_op(
|
||||
|
||||
case DocumentRange::kFrames:
|
||||
{
|
||||
frame_t srcFrameBegin, srcFrameStep, srcFrameEnd;
|
||||
frame_t dstFrameBegin, dstFrameStep;
|
||||
frame_t srcFrameBegin = 0, srcFrameStep, srcFrameEnd = 0;
|
||||
frame_t dstFrameBegin = 0, dstFrameStep;
|
||||
|
||||
switch (op) {
|
||||
|
||||
|
@ -1299,6 +1299,7 @@ static void ase_file_read_frame_tags_chunk(FILE* f, FrameTags* frameTags)
|
||||
FrameTag* tag = new FrameTag(from, to);
|
||||
tag->setColor(doc::rgba(r, g, b, 255));
|
||||
tag->setName(name);
|
||||
tag->setAniDir((AniDir)aniDir);
|
||||
frameTags->add(tag);
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ void fli_write_header(FILE *f, s_fli_header *fli_header)
|
||||
fli_write_short(f, fli_header->flags); /* 14 */
|
||||
if (fli_header->magic == HEADER_FLI) {
|
||||
/* FLI saves speed in 1/70s */
|
||||
fli_write_short(f, fli_header->speed / 14); /* 16 */
|
||||
fli_write_short(f, (unsigned short)fli_header->speed / 14); /* 16 */
|
||||
} else {
|
||||
if (fli_header->magic == HEADER_FLC) {
|
||||
/* FLC saves speed in 1/1000s */
|
||||
@ -375,8 +375,8 @@ int fli_write_color_2(FILE *f, s_fli_header *fli_header, unsigned char *old_cmap
|
||||
}
|
||||
if (cnt_col>0) {
|
||||
num_packets++;
|
||||
fli_write_char(f, cnt_skip);
|
||||
fli_write_char(f, cnt_col);
|
||||
fli_write_char(f, (unsigned char)cnt_skip);
|
||||
fli_write_char(f, (unsigned char)cnt_col);
|
||||
while (cnt_col>0) {
|
||||
fli_write_char(f, cmap[col_start++]);
|
||||
fli_write_char(f, cmap[col_start++]);
|
||||
@ -510,7 +510,7 @@ void fli_write_brun(FILE *f, s_fli_header *fli_header, unsigned char *framebuf)
|
||||
tc=0;
|
||||
}
|
||||
bc++;
|
||||
fli_write_char(f, pc);
|
||||
fli_write_char(f, (unsigned char)pc);
|
||||
fli_write_char(f, linebuf[xc]);
|
||||
t1=xc+pc;
|
||||
} else {
|
||||
@ -533,7 +533,7 @@ void fli_write_brun(FILE *f, s_fli_header *fli_header, unsigned char *framebuf)
|
||||
}
|
||||
lineend=ftell(f);
|
||||
fseek(f, linepos, SEEK_SET);
|
||||
fli_write_char(f, bc);
|
||||
fli_write_char(f, (unsigned char)bc);
|
||||
fseek(f, lineend, SEEK_SET);
|
||||
}
|
||||
|
||||
@ -626,7 +626,7 @@ void fli_write_lc(FILE *f, s_fli_header *fli_header, unsigned char *old_framebuf
|
||||
while ((linebuf[xc]==old_linebuf[xc]) && (xc<fli_header->width) && (sc<255)) {
|
||||
xc++; sc++;
|
||||
}
|
||||
fli_write_char(f, sc);
|
||||
fli_write_char(f, (unsigned char)sc);
|
||||
cc=1;
|
||||
while ((linebuf[xc]==linebuf[xc+cc]) && ((xc+cc)<fli_header->width) && (cc<120)) {
|
||||
cc++;
|
||||
@ -650,14 +650,14 @@ void fli_write_lc(FILE *f, s_fli_header *fli_header, unsigned char *old_framebuf
|
||||
tc++;
|
||||
} while ((tc<120) && (cc<9) && (sc<4) && ((xc+tc)<fli_header->width));
|
||||
bc++;
|
||||
fli_write_char(f, tc);
|
||||
fli_write_char(f, (unsigned char)tc);
|
||||
fwrite(linebuf+xc, tc, 1, f);
|
||||
xc+=tc;
|
||||
}
|
||||
}
|
||||
lineend=ftell(f);
|
||||
fseek(f, linepos, SEEK_SET);
|
||||
fli_write_char(f, bc);
|
||||
fli_write_char(f, (unsigned char)bc);
|
||||
fseek(f, lineend, SEEK_SET);
|
||||
}
|
||||
|
||||
@ -719,7 +719,7 @@ void fli_read_lc_2(FILE *f, s_fli_header *fli_header, unsigned char *old_framebu
|
||||
xc+=ps << 1;
|
||||
}
|
||||
}
|
||||
if (lpf) pos[xc]=lpn;
|
||||
if (lpf) pos[xc]=(unsigned char)lpn;
|
||||
yc++;
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,9 @@ bool FliFormat::onLoad(FileOp* fop)
|
||||
int c, w, h;
|
||||
frame_t frpos_in;
|
||||
frame_t frpos_out;
|
||||
#ifdef USE_LINK
|
||||
int index = 0; // TODO this is used to create linked cels
|
||||
#endif
|
||||
|
||||
// Open the file to read in binary mode
|
||||
FileHandle f(open_file_with_exception(fop->filename, "rb"));
|
||||
|
@ -192,8 +192,8 @@ bool TgaFormat::onLoad(FileOp* fop)
|
||||
unsigned char image_id[256], image_palette[256][3], rgb[4];
|
||||
unsigned char id_length, palette_type, image_type, palette_entry_size;
|
||||
unsigned char bpp, descriptor_bits;
|
||||
short unsigned int first_color, palette_colors;
|
||||
short unsigned int left, top, image_width, image_height;
|
||||
short unsigned int palette_colors;
|
||||
short unsigned int image_width, image_height;
|
||||
unsigned int c, i, x, y, yc;
|
||||
int compressed;
|
||||
|
||||
@ -202,11 +202,11 @@ bool TgaFormat::onLoad(FileOp* fop)
|
||||
id_length = fgetc(f);
|
||||
palette_type = fgetc(f);
|
||||
image_type = fgetc(f);
|
||||
first_color = fgetw(f);
|
||||
fgetw(f); // first_color
|
||||
palette_colors = fgetw(f);
|
||||
palette_entry_size = fgetc(f);
|
||||
left = fgetw(f);
|
||||
top = fgetw(f);
|
||||
fgetw(f); // "left" field
|
||||
fgetw(f); // "top" field
|
||||
image_width = fgetw(f);
|
||||
image_height = fgetw(f);
|
||||
bpp = fgetc(f);
|
||||
|
@ -19,18 +19,18 @@ TEST(IniFile, Basic)
|
||||
|
||||
set_config_file("_test.ini");
|
||||
|
||||
EXPECT_EQ(false, get_config_bool("A", "a", false));
|
||||
EXPECT_EQ(true, get_config_bool("A", "b", true));
|
||||
EXPECT_EQ(0, get_config_bool("B", "a", 0));
|
||||
EXPECT_EQ(1, get_config_bool("B", "b", 1));
|
||||
EXPECT_FALSE(get_config_bool("A", "a", false));
|
||||
EXPECT_TRUE(get_config_bool("A", "b", true));
|
||||
EXPECT_FALSE(get_config_bool("B", "a", 0));
|
||||
EXPECT_TRUE(get_config_bool("B", "b", 1));
|
||||
|
||||
set_config_bool("A", "a", true);
|
||||
set_config_bool("A", "b", false);
|
||||
set_config_int("B", "a", 2);
|
||||
set_config_int("B", "b", 3);
|
||||
|
||||
EXPECT_EQ(true, get_config_bool("A", "a", false));
|
||||
EXPECT_EQ(false, get_config_bool("A", "b", true));
|
||||
EXPECT_TRUE(get_config_bool("A", "a", false));
|
||||
EXPECT_FALSE(get_config_bool("A", "b", true));
|
||||
EXPECT_EQ(2, get_config_int("B", "a", 0));
|
||||
EXPECT_EQ(3, get_config_int("B", "b", 1));
|
||||
}
|
||||
|
@ -419,8 +419,6 @@ void StandbyState::transformSelection(Editor* editor, MouseMessage* msg, HandleT
|
||||
base::UniquePtr<Image> tmpImage(NewImageFromMask(editor->getDocumentLocation()));
|
||||
gfx::Point origin = document->mask()->bounds().getOrigin();
|
||||
int opacity = 255;
|
||||
Sprite* sprite = editor->sprite();
|
||||
Layer* layer = editor->layer();
|
||||
PixelsMovementPtr pixelsMovement(
|
||||
new PixelsMovement(UIContext::instance(),
|
||||
editor->getDocumentLocation(),
|
||||
|
@ -483,7 +483,6 @@ void FileSelector::updateLocation()
|
||||
IFileItem* fileItem = currentFolder;
|
||||
std::list<IFileItem*> locations;
|
||||
int selected_index = -1;
|
||||
int newItem;
|
||||
|
||||
while (fileItem != NULL) {
|
||||
locations.push_front(fileItem);
|
||||
@ -518,8 +517,8 @@ void FileSelector::updateLocation()
|
||||
|
||||
// Add paths from recent files list
|
||||
{
|
||||
newItem = m_location->addItem("");
|
||||
newItem = m_location->addItem("-------- Recent Paths --------");
|
||||
m_location->addItem("");
|
||||
m_location->addItem("-------- Recent Paths --------");
|
||||
|
||||
RecentFiles::const_iterator it = App::instance()->getRecentFiles()->paths_begin();
|
||||
RecentFiles::const_iterator end = App::instance()->getRecentFiles()->paths_end();
|
||||
|
@ -182,8 +182,8 @@ protected:
|
||||
};
|
||||
|
||||
NewsListBox::NewsListBox()
|
||||
: m_loader(nullptr)
|
||||
, m_timer(250, this)
|
||||
: m_timer(250, this)
|
||||
, m_loader(nullptr)
|
||||
{
|
||||
m_timer.Tick.connect(&NewsListBox::onTick, this);
|
||||
|
||||
@ -266,8 +266,6 @@ void NewsListBox::parseFile(const std::string& filename)
|
||||
TiXmlElement* titleXml = itemXml->FirstChildElement("title");
|
||||
TiXmlElement* descXml = itemXml->FirstChildElement("description");
|
||||
TiXmlElement* linkXml = itemXml->FirstChildElement("link");
|
||||
TiXmlElement* guidXml = itemXml->FirstChildElement("guid");
|
||||
TiXmlElement* pubDateXml = itemXml->FirstChildElement("pubDate");
|
||||
|
||||
std::string link = linkXml->GetText();
|
||||
std::string title = titleXml->GetText();
|
||||
|
@ -357,7 +357,6 @@ void Tabs::onPaint(PaintEvent& ev)
|
||||
|
||||
int startX = m_border*guiscale();
|
||||
double t = double(m_ani_t)/double(m_ani_T);
|
||||
Tab* prevTab = nullptr;
|
||||
|
||||
// For each tab...
|
||||
int i = 0;
|
||||
@ -375,7 +374,6 @@ void Tabs::onPaint(PaintEvent& ev)
|
||||
drawTab(g, box, tab, 0, (tab == m_hot), false);
|
||||
|
||||
box.x = box.x2();
|
||||
prevTab = tab;
|
||||
++i;
|
||||
}
|
||||
|
||||
@ -449,8 +447,6 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& _box, Tab* tab, int dy,
|
||||
box.w = ui::guiscale()*8;
|
||||
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
|
||||
gfx::Color text_color;
|
||||
gfx::Color face_color;
|
||||
int clipTextRightSide;
|
||||
|
||||
gfx::Rect closeBox = getTabCloseButtonBounds(tab, box);
|
||||
@ -461,17 +457,6 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& _box, Tab* tab, int dy,
|
||||
clipTextRightSide = closeBox.w;
|
||||
}
|
||||
|
||||
// Selected
|
||||
if (selected) {
|
||||
text_color = theme->colors.tabActiveText();
|
||||
face_color = theme->colors.tabActiveFace();
|
||||
}
|
||||
// Non-selected
|
||||
else {
|
||||
text_color = theme->colors.tabNormalText();
|
||||
face_color = theme->colors.tabNormalFace();
|
||||
}
|
||||
|
||||
skin::Style::State state;
|
||||
if (selected) state += skin::Style::active();
|
||||
if (hover) state += skin::Style::hover();
|
||||
@ -590,7 +575,6 @@ void Tabs::calculateHot()
|
||||
if (m_isDragging)
|
||||
return;
|
||||
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
|
||||
gfx::Rect rect = getBounds();
|
||||
gfx::Rect box(rect.x+m_border*guiscale(), rect.y, 0, rect.h-1);
|
||||
gfx::Point mousePos = ui::get_mouse_position();
|
||||
|
@ -19,7 +19,7 @@ namespace app {
|
||||
using namespace doc;
|
||||
|
||||
bool get_shrink_rect(int *x1, int *y1, int *x2, int *y2,
|
||||
Image *image, int refpixel)
|
||||
Image *image, color_t refpixel)
|
||||
{
|
||||
#define SHRINK_SIDE(u_begin, u_op, u_final, u_add, \
|
||||
v_begin, v_op, v_final, v_add, U, V, var) \
|
||||
|
@ -9,6 +9,8 @@
|
||||
#define APP_UTIL_AUTOCROP_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "doc/color.h"
|
||||
|
||||
namespace doc {
|
||||
class Image;
|
||||
}
|
||||
@ -16,7 +18,7 @@ namespace doc {
|
||||
namespace app {
|
||||
|
||||
bool get_shrink_rect(int* x1, int* y1, int* x2, int* y2,
|
||||
doc::Image *image, int refpixel);
|
||||
doc::Image *image, doc::color_t refpixel);
|
||||
bool get_shrink_rect2(int* x1, int* y1, int* x2, int* y2,
|
||||
doc::Image* image, doc::Image* regimage);
|
||||
|
||||
|
@ -28,7 +28,6 @@ Image* load_pic_file(const char* filename, int* x, int* y, Palette** palette)
|
||||
{
|
||||
base::UniquePtr<Image> image;
|
||||
int size, compression;
|
||||
int image_size;
|
||||
int block_size;
|
||||
int block_type;
|
||||
int version;
|
||||
@ -51,7 +50,7 @@ Image* load_pic_file(const char* filename, int* x, int* y, Palette** palette)
|
||||
*y = ((short)base::fgetw(f)); // Y offset
|
||||
bpp = std::fgetc(f); // bits per pixel (must be 8)
|
||||
compression = std::fgetc(f); // compression flag (must be 0)
|
||||
image_size = base::fgetl(f); // image size (in bytes)
|
||||
base::fgetl(f); // image size (in bytes)
|
||||
std::fgetc(f); // reserved
|
||||
|
||||
if (bpp != 8 || compression != 0) {
|
||||
|
@ -71,8 +71,8 @@ template<> std::string convert_to(const Sha1& from)
|
||||
template<> Version convert_to(const std::string& from)
|
||||
{
|
||||
Version result;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
std::string::size_type i = 0;
|
||||
std::string::size_type j = 0;
|
||||
while (j != std::string::npos) {
|
||||
j = from.find('.', i);
|
||||
std::string digitString = from.substr(i, j - i);
|
||||
|
@ -12,16 +12,18 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
using namespace base;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable: 4996)
|
||||
#define posix_open _open
|
||||
#define posix_close _close
|
||||
#define posix_read _read
|
||||
#define posix_write _write
|
||||
#else
|
||||
#define posix_open open
|
||||
#define posix_close close
|
||||
#define posix_read read
|
||||
#define posix_write write
|
||||
#endif
|
||||
|
||||
TEST(FileHandle, Descriptors)
|
||||
@ -37,23 +39,23 @@ TEST(FileHandle, Descriptors)
|
||||
// Create file.
|
||||
ASSERT_NO_THROW({
|
||||
int fd = open_file_descriptor_with_exception(fn, "wb");
|
||||
close(fd);
|
||||
posix_close(fd);
|
||||
});
|
||||
|
||||
// Truncate file.
|
||||
ASSERT_NO_THROW({
|
||||
int fd = open_file_descriptor_with_exception(fn, "wb");
|
||||
EXPECT_EQ(6, write(fd, "hello", 6));
|
||||
close(fd);
|
||||
EXPECT_EQ(6, posix_write(fd, "hello", 6));
|
||||
posix_close(fd);
|
||||
});
|
||||
|
||||
// Read.
|
||||
ASSERT_NO_THROW({
|
||||
int fd = open_file_descriptor_with_exception(fn, "rb");
|
||||
std::vector<char> buf(6);
|
||||
EXPECT_EQ(6, read(fd, &buf[0], 6));
|
||||
EXPECT_EQ(6, posix_read(fd, &buf[0], 6));
|
||||
EXPECT_EQ("hello", std::string(&buf[0]));
|
||||
close(fd);
|
||||
posix_close(fd);
|
||||
});
|
||||
|
||||
ASSERT_NO_THROW({
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Base Library
|
||||
// Copyright (c) 2001-2014 David Capello
|
||||
// Copyright (c) 2001-2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -16,11 +16,6 @@
|
||||
#include "base/mutex.h"
|
||||
#include "base/scoped_lock.h"
|
||||
|
||||
// It is used so MSVC doesn't complain about deprecated POSIX names.
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
#if !defined MEMLEAK // Without leak detection
|
||||
@ -52,7 +47,11 @@ void base_free(void* mem)
|
||||
char* base_strdup(const char* string)
|
||||
{
|
||||
assert(string != NULL);
|
||||
#ifdef _MSC_VER
|
||||
return _strdup(string);
|
||||
#else
|
||||
return strdup(string);
|
||||
#endif
|
||||
}
|
||||
|
||||
#else // With leak detection
|
||||
|
@ -523,9 +523,8 @@ double algo_spline_get_tan(double x0, double y0, double x1, double y1,
|
||||
double x2, double y2, double x3, double y3,
|
||||
double in_x)
|
||||
{
|
||||
double out_x, old_x, old_dx, old_dy;
|
||||
int npts;
|
||||
double out_x, old_dx, old_x;
|
||||
double out_y, old_dy;
|
||||
|
||||
/* Derivatives of x(t) and y(t). */
|
||||
double x, dx, ddx, dddx;
|
||||
@ -572,7 +571,6 @@ double algo_spline_get_tan(double x0, double y0, double x1, double y1,
|
||||
y = y0;
|
||||
|
||||
out_x = x0;
|
||||
out_y = y0;
|
||||
|
||||
old_x = x0;
|
||||
old_dx = dx;
|
||||
@ -589,7 +587,6 @@ double algo_spline_get_tan(double x0, double y0, double x1, double y1,
|
||||
y += dy;
|
||||
|
||||
out_x = x;
|
||||
out_y = y;
|
||||
if (out_x > in_x) {
|
||||
dx = old_dx + (dx-old_dx) * (in_x-old_x) / (out_x-old_x);
|
||||
dy = old_dy + (dy-old_dy) * (in_x-old_x) / (out_x-old_x);
|
||||
|
@ -233,7 +233,7 @@ public:
|
||||
void feedLine(Image* spr, int spr_x, int spr_y) {
|
||||
ASSERT(m_it != m_end);
|
||||
|
||||
int c = spr->getPixel(spr_x, spr_y);
|
||||
color_t c = spr->getPixel(spr_x, spr_y);
|
||||
if (c != m_mask_color)
|
||||
*m_it = c;
|
||||
++m_it;
|
||||
|
@ -58,7 +58,6 @@ namespace doc {
|
||||
|
||||
private:
|
||||
iterator m_begin, m_end;
|
||||
Flags m_flags;
|
||||
};
|
||||
|
||||
} // namespace doc
|
||||
|
@ -16,8 +16,8 @@ FrameTag::FrameTag(frame_t from, frame_t to)
|
||||
: Object(ObjectType::FrameTag)
|
||||
, m_from(from)
|
||||
, m_to(to)
|
||||
, m_name("Tag")
|
||||
, m_color(rgba(0, 0, 0, 255))
|
||||
, m_name("Tag")
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2014 David Capello
|
||||
// Copyright (c) 2001-2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -209,7 +209,7 @@ namespace doc {
|
||||
}
|
||||
|
||||
bool operator==(int b) const {
|
||||
return (color_t(*this) == b);
|
||||
return (color_t(*this) == color_t(b));
|
||||
}
|
||||
|
||||
bool operator==(color_t b) const {
|
||||
@ -221,7 +221,7 @@ namespace doc {
|
||||
}
|
||||
|
||||
bool operator!=(int b) const {
|
||||
return (color_t(*this) != b);
|
||||
return (color_t(*this) != color_t(b));
|
||||
}
|
||||
|
||||
bool operator!=(color_t b) const {
|
||||
@ -241,7 +241,7 @@ namespace doc {
|
||||
};
|
||||
|
||||
inline bool operator==(int a, const BitPixelAccess& b) {
|
||||
return (a == color_t(b));
|
||||
return (color_t(a) == color_t(b));
|
||||
}
|
||||
|
||||
inline bool operator==(color_t a, const BitPixelAccess& b) {
|
||||
@ -249,7 +249,7 @@ namespace doc {
|
||||
}
|
||||
|
||||
inline bool operator!=(int a, const BitPixelAccess& b) {
|
||||
return (a != color_t(b));
|
||||
return (color_t(a) != color_t(b));
|
||||
}
|
||||
|
||||
inline bool operator!=(color_t a, const BitPixelAccess& b) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2014 David Capello
|
||||
// Copyright (c) 2001-2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -308,9 +308,10 @@ void Mask::crop(const Image *image)
|
||||
}
|
||||
|
||||
int beg_x1, beg_y1, beg_x2, beg_y2;
|
||||
int c, x1, y1, x2, y2, old_color;
|
||||
int c, x1, y1, x2, y2;
|
||||
int done_count = 0;
|
||||
int done;
|
||||
color_t old_color;
|
||||
|
||||
if (!m_bitmap)
|
||||
return;
|
||||
|
@ -153,9 +153,9 @@ bool Region::contains(const PointT<int>& pt) const
|
||||
Region::Overlap Region::contains(const Rect& rect) const
|
||||
{
|
||||
static_assert(
|
||||
Out == PIXMAN_REGION_OUT &&
|
||||
In == PIXMAN_REGION_IN &&
|
||||
Part == PIXMAN_REGION_PART, "Pixman constants have changed");
|
||||
int(Out) == int(PIXMAN_REGION_OUT) &&
|
||||
int(In) == int(PIXMAN_REGION_IN) &&
|
||||
int(Part) == int(PIXMAN_REGION_PART), "Pixman constants have changed");
|
||||
|
||||
pixman_box32 box = { rect.x, rect.y, rect.x2(), rect.y2() };
|
||||
return (Region::Overlap)pixman_region32_contains_rectangle(&m_region, &box);
|
||||
|
@ -14,10 +14,6 @@
|
||||
#include <allegro.h>
|
||||
#include <winalleg.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4996) // To avoid MSVC warning about std::copy() with unsafe arguments
|
||||
#endif
|
||||
|
||||
namespace she {
|
||||
|
||||
void ClipboardWin32::dispose()
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2001-2014 David Capello
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -9,12 +9,8 @@
|
||||
#include <algorithm>
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4996) // To void MSVC warning about std::copy() with unsafe arguments
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
void get_system_clipboard_text(std::string& text)
|
||||
{
|
||||
if (IsClipboardFormatAvailable(CF_UNICODETEXT)) {
|
||||
|
@ -117,7 +117,7 @@ TEST(JGrid, SameWidth2x1Grid)
|
||||
//
|
||||
// 2 (separator)
|
||||
// _|_
|
||||
// / \
|
||||
// | |
|
||||
// 10 2 0 2 10
|
||||
// +---+-------+
|
||||
// | 1 | 2 | 10
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2001-2013 David Capello
|
||||
// Copyright (C) 2001-2013, 2015 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -138,10 +138,8 @@ bool ScrollBar::onProcessMessage(Message* msg)
|
||||
gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();
|
||||
View* view = static_cast<View*>(getParent());
|
||||
int pos, len, bar_size, viewport_size;
|
||||
int old_pos;
|
||||
|
||||
getScrollBarInfo(&pos, &len, &bar_size, &viewport_size);
|
||||
old_pos = pos;
|
||||
|
||||
if (bar_size > len) {
|
||||
Point scroll = view->getViewScroll();
|
||||
|
43
third_party/giflib/lib/dgif_lib.c
vendored
43
third_party/giflib/lib/dgif_lib.c
vendored
@ -12,15 +12,20 @@ two modules will be linked. Preserve this property!
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#endif /* _WIN32 */
|
||||
#include <io.h>
|
||||
#define posix_open _open
|
||||
#define posix_close _close
|
||||
#define posix_fdopen _fdopen
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#define posix_open open
|
||||
#define posix_close close
|
||||
#define posix_fdopen fdopen
|
||||
#endif
|
||||
|
||||
#include "gif_lib.h"
|
||||
#include "gif_lib_private.h"
|
||||
@ -54,7 +59,7 @@ DGifOpenFileName(const char *FileName, int *Error)
|
||||
int FileHandle;
|
||||
GifFileType *GifFile;
|
||||
|
||||
if ((FileHandle = open(FileName, O_RDONLY)) == -1) {
|
||||
if ((FileHandle = posix_open(FileName, O_RDONLY)) == -1) {
|
||||
if (Error != NULL)
|
||||
*Error = D_GIF_ERR_OPEN_FAILED;
|
||||
return NULL;
|
||||
@ -81,7 +86,7 @@ DGifOpenFileHandle(int FileHandle, int *Error)
|
||||
if (GifFile == NULL) {
|
||||
if (Error != NULL)
|
||||
*Error = D_GIF_ERR_NOT_ENOUGH_MEM;
|
||||
(void)close(FileHandle);
|
||||
posix_close(FileHandle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -95,7 +100,7 @@ DGifOpenFileHandle(int FileHandle, int *Error)
|
||||
if (Private == NULL) {
|
||||
if (Error != NULL)
|
||||
*Error = D_GIF_ERR_NOT_ENOUGH_MEM;
|
||||
(void)close(FileHandle);
|
||||
posix_close(FileHandle);
|
||||
free((char *)GifFile);
|
||||
return NULL;
|
||||
}
|
||||
@ -103,7 +108,7 @@ DGifOpenFileHandle(int FileHandle, int *Error)
|
||||
_setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
f = fdopen(FileHandle, "rb"); /* Make it into a stream: */
|
||||
f = posix_fdopen(FileHandle, "rb"); /* Make it into a stream: */
|
||||
|
||||
/*@-mustfreeonly@*/
|
||||
GifFile->Private = (void *)Private;
|
||||
@ -256,7 +261,7 @@ DGifGetScreenDesc(GifFileType *GifFile)
|
||||
SortFlag = (Buf[0] & 0x08) != 0;
|
||||
BitsPerPixel = (Buf[0] & 0x07) + 1;
|
||||
GifFile->SBackGroundColor = Buf[1];
|
||||
GifFile->AspectByte = Buf[2];
|
||||
GifFile->AspectByte = Buf[2];
|
||||
if (Buf[0] & 0x80) { /* Do we have global color map? */
|
||||
int i;
|
||||
|
||||
@ -373,7 +378,7 @@ DGifGetImageDesc(GifFileType *GifFile)
|
||||
}
|
||||
|
||||
/* Get the image local color map: */
|
||||
for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) {
|
||||
for (i = 0; i < (unsigned int)GifFile->Image.ColorMap->ColorCount; i++) {
|
||||
if (READ(GifFile, Buf, 3) != 3) {
|
||||
GifFreeMapObject(GifFile->Image.ColorMap);
|
||||
GifFile->Error = D_GIF_ERR_READ_FAILED;
|
||||
@ -983,7 +988,7 @@ DGifDecompressInput(GifFileType *GifFile, int *Code)
|
||||
GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
|
||||
return GIF_ERROR;
|
||||
}
|
||||
|
||||
|
||||
while (Private->CrntShiftState < Private->RunningBits) {
|
||||
/* Needs to get more bytes from input stream for next code: */
|
||||
if (DGifBufferedInput(GifFile, Private->Buf, &NextByte) == GIF_ERROR) {
|
||||
@ -1096,19 +1101,19 @@ DGifSlurp(GifFileType *GifFile)
|
||||
|
||||
if (sp->ImageDesc.Interlace) {
|
||||
int i, j;
|
||||
/*
|
||||
* The way an interlaced image should be read -
|
||||
/*
|
||||
* The way an interlaced image should be read -
|
||||
* offsets and jumps...
|
||||
*/
|
||||
int InterlacedOffset[] = { 0, 4, 2, 1 };
|
||||
int InterlacedJumps[] = { 8, 8, 4, 2 };
|
||||
/* Need to perform 4 passes on the image */
|
||||
for (i = 0; i < 4; i++)
|
||||
for (j = InterlacedOffset[i];
|
||||
for (j = InterlacedOffset[i];
|
||||
j < sp->ImageDesc.Height;
|
||||
j += InterlacedJumps[i]) {
|
||||
if (DGifGetLine(GifFile,
|
||||
sp->RasterBits+j*sp->ImageDesc.Width,
|
||||
if (DGifGetLine(GifFile,
|
||||
sp->RasterBits+j*sp->ImageDesc.Width,
|
||||
sp->ImageDesc.Width) == GIF_ERROR)
|
||||
return GIF_ERROR;
|
||||
}
|
||||
@ -1133,7 +1138,7 @@ DGifSlurp(GifFileType *GifFile)
|
||||
/* Create an extension block with our data */
|
||||
if (ExtData != NULL) {
|
||||
if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount,
|
||||
&GifFile->ExtensionBlocks,
|
||||
&GifFile->ExtensionBlocks,
|
||||
ExtFunction, ExtData[0], &ExtData[1])
|
||||
== GIF_ERROR)
|
||||
return (GIF_ERROR);
|
||||
@ -1145,7 +1150,7 @@ DGifSlurp(GifFileType *GifFile)
|
||||
if (ExtData != NULL)
|
||||
if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount,
|
||||
&GifFile->ExtensionBlocks,
|
||||
CONTINUE_EXT_FUNC_CODE,
|
||||
CONTINUE_EXT_FUNC_CODE,
|
||||
ExtData[0], &ExtData[1]) == GIF_ERROR)
|
||||
return (GIF_ERROR);
|
||||
}
|
||||
|
73
third_party/giflib/lib/egif_lib.c
vendored
73
third_party/giflib/lib/egif_lib.c
vendored
@ -8,9 +8,6 @@ two modules will be linked. Preserve this property!
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -18,10 +15,17 @@ two modules will be linked. Preserve this property!
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <io.h>
|
||||
#define posix_open _open
|
||||
#define posix_close _close
|
||||
#define posix_fdopen _fdopen
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#endif /* _WIN32 */
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#define posix_open open
|
||||
#define posix_close close
|
||||
#define posix_fdopen fdopen
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "gif_lib.h"
|
||||
@ -37,8 +41,8 @@ static const GifPixelType CodeMask[] = {
|
||||
static int EGifPutWord(int Word, GifFileType * GifFile);
|
||||
static int EGifSetupCompress(GifFileType * GifFile);
|
||||
static int EGifCompressLine(GifFileType * GifFile, GifPixelType * Line,
|
||||
int LineLen);
|
||||
static int EGifCompressOutput(GifFileType * GifFile, int Code);
|
||||
const int LineLen);
|
||||
static int EGifCompressOutput(GifFileType * GifFile, const int Code);
|
||||
static int EGifBufferedOutput(GifFileType * GifFile, GifByteType * Buf,
|
||||
int c);
|
||||
|
||||
@ -60,11 +64,11 @@ EGifOpenFileName(const char *FileName, const bool TestExistence, int *Error)
|
||||
GifFileType *GifFile;
|
||||
|
||||
if (TestExistence)
|
||||
FileHandle = open(FileName, O_WRONLY | O_CREAT | O_EXCL,
|
||||
S_IREAD | S_IWRITE);
|
||||
FileHandle = posix_open(FileName, O_WRONLY | O_CREAT | O_EXCL,
|
||||
S_IREAD | S_IWRITE);
|
||||
else
|
||||
FileHandle = open(FileName, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
S_IREAD | S_IWRITE);
|
||||
FileHandle = posix_open(FileName, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
S_IREAD | S_IWRITE);
|
||||
|
||||
if (FileHandle == -1) {
|
||||
if (Error != NULL)
|
||||
@ -73,7 +77,7 @@ EGifOpenFileName(const char *FileName, const bool TestExistence, int *Error)
|
||||
}
|
||||
GifFile = EGifOpenFileHandle(FileHandle, Error);
|
||||
if (GifFile == (GifFileType *) NULL)
|
||||
(void)close(FileHandle);
|
||||
(void)posix_close(FileHandle);
|
||||
return GifFile;
|
||||
}
|
||||
|
||||
@ -117,7 +121,7 @@ EGifOpenFileHandle(const int FileHandle, int *Error)
|
||||
_setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
f = fdopen(FileHandle, "wb"); /* Make it into a stream: */
|
||||
f = posix_fdopen(FileHandle, "wb"); /* Make it into a stream: */
|
||||
|
||||
GifFile->Private = (void *)Private;
|
||||
Private->FileHandle = FileHandle;
|
||||
@ -192,7 +196,7 @@ EGifGetGifVersion(GifFileType *GifFile)
|
||||
GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
|
||||
int i, j;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Bulletproofing - always write GIF89 if we need to.
|
||||
* Note, we don't clear the gif89 flag here because
|
||||
* users of the sequential API might have called EGifSetGifVersion()
|
||||
@ -219,7 +223,7 @@ EGifGetGifVersion(GifFileType *GifFile)
|
||||
|| function == APPLICATION_EXT_FUNC_CODE)
|
||||
Private->gif89 = true;
|
||||
}
|
||||
|
||||
|
||||
if (Private->gif89)
|
||||
return GIF89_STAMP;
|
||||
else
|
||||
@ -228,7 +232,7 @@ EGifGetGifVersion(GifFileType *GifFile)
|
||||
|
||||
/******************************************************************************
|
||||
Set the GIF version. In the extremely unlikely event that there is ever
|
||||
another version, replace the bool argument with an enum in which the
|
||||
another version, replace the bool argument with an enum in which the
|
||||
GIF87 value is 0 (numerically the same as bool false) and the GIF89 value
|
||||
is 1 (numerically the same as bool true). That way we'll even preserve
|
||||
object-file compatibility!
|
||||
@ -243,7 +247,7 @@ void EGifSetGifVersion(GifFileType *GifFile, const bool gif89)
|
||||
/******************************************************************************
|
||||
All writes to the GIF should go through this.
|
||||
******************************************************************************/
|
||||
static int InternalWrite(GifFileType *GifFileOut,
|
||||
static int InternalWrite(GifFileType *GifFileOut,
|
||||
const unsigned char *buf, size_t len)
|
||||
{
|
||||
GifFilePrivateType *Private = (GifFilePrivateType*)GifFileOut->Private;
|
||||
@ -471,8 +475,9 @@ EGifPutLine(GifFileType * GifFile, GifPixelType *Line, int LineLen)
|
||||
Put one pixel (Pixel) into GIF file.
|
||||
******************************************************************************/
|
||||
int
|
||||
EGifPutPixel(GifFileType *GifFile, GifPixelType Pixel)
|
||||
EGifPutPixel(GifFileType *GifFile, const GifPixelType _Pixel)
|
||||
{
|
||||
GifPixelType Pixel = _Pixel;
|
||||
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
|
||||
|
||||
if (!IS_WRITEABLE(Private)) {
|
||||
@ -563,7 +568,7 @@ EGifPutExtensionLeader(GifFileType *GifFile, const int ExtCode)
|
||||
Put extension block data (see GIF manual) into a GIF file.
|
||||
******************************************************************************/
|
||||
int
|
||||
EGifPutExtensionBlock(GifFileType *GifFile,
|
||||
EGifPutExtensionBlock(GifFileType *GifFile,
|
||||
const int ExtLen,
|
||||
const void *Extension)
|
||||
{
|
||||
@ -662,7 +667,7 @@ size_t EGifGCBToExtension(const GraphicsControlBlock *GCB,
|
||||
Replace the Graphics Control Block for a saved image, if it exists.
|
||||
******************************************************************************/
|
||||
|
||||
int EGifGCBToSavedExtension(const GraphicsControlBlock *GCB,
|
||||
int EGifGCBToSavedExtension(const GraphicsControlBlock *GCB,
|
||||
GifFileType *GifFile, int ImageIndex)
|
||||
{
|
||||
int i;
|
||||
@ -710,7 +715,7 @@ EGifPutCode(GifFileType *GifFile, int CodeSize, const GifByteType *CodeBlock)
|
||||
}
|
||||
|
||||
/* No need to dump code size as Compression set up does any for us: */
|
||||
/*
|
||||
/*
|
||||
* Buf = CodeSize;
|
||||
* if (InternalWrite(GifFile, &Buf, 1) != 1) {
|
||||
* GifFile->Error = E_GIF_ERR_WRITE_FAILED;
|
||||
@ -893,7 +898,7 @@ EGifCompressLine(GifFileType *GifFile,
|
||||
|
||||
while (i < LineLen) { /* Decode LineLen items. */
|
||||
Pixel = Line[i++]; /* Get next pixel from stream. */
|
||||
/* Form a new unique key to search hash table for the code combines
|
||||
/* Form a new unique key to search hash table for the code combines
|
||||
* CrntCode as Prefix string with Pixel as postfix char.
|
||||
*/
|
||||
NewKey = (((uint32_t) CrntCode) << 8) + Pixel;
|
||||
@ -1049,9 +1054,9 @@ EGifBufferedOutput(GifFileType *GifFile,
|
||||
******************************************************************************/
|
||||
|
||||
static int
|
||||
EGifWriteExtensions(GifFileType *GifFileOut,
|
||||
ExtensionBlock *ExtensionBlocks,
|
||||
int ExtensionBlockCount)
|
||||
EGifWriteExtensions(GifFileType *GifFileOut,
|
||||
ExtensionBlock *ExtensionBlocks,
|
||||
int ExtensionBlockCount)
|
||||
{
|
||||
if (ExtensionBlocks) {
|
||||
ExtensionBlock *ep;
|
||||
@ -1074,9 +1079,9 @@ EGifWriteExtensions(GifFileType *GifFileOut,
|
||||
}
|
||||
|
||||
int
|
||||
EGifSpew(GifFileType *GifFileOut)
|
||||
EGifSpew(GifFileType *GifFileOut)
|
||||
{
|
||||
int i, j;
|
||||
int i, j;
|
||||
|
||||
if (EGifPutScreenDesc(GifFileOut,
|
||||
GifFileOut->SWidth,
|
||||
@ -1096,7 +1101,7 @@ EGifSpew(GifFileType *GifFileOut)
|
||||
if (sp->RasterBits == NULL)
|
||||
continue;
|
||||
|
||||
if (EGifWriteExtensions(GifFileOut,
|
||||
if (EGifWriteExtensions(GifFileOut,
|
||||
sp->ExtensionBlocks,
|
||||
sp->ExtensionBlockCount) == GIF_ERROR)
|
||||
return (GIF_ERROR);
|
||||
@ -1111,8 +1116,8 @@ EGifSpew(GifFileType *GifFileOut)
|
||||
return (GIF_ERROR);
|
||||
|
||||
if (sp->ImageDesc.Interlace) {
|
||||
/*
|
||||
* The way an interlaced image should be written -
|
||||
/*
|
||||
* The way an interlaced image should be written -
|
||||
* offsets and jumps...
|
||||
*/
|
||||
int InterlacedOffset[] = { 0, 4, 2, 1 };
|
||||
@ -1120,11 +1125,11 @@ EGifSpew(GifFileType *GifFileOut)
|
||||
int k;
|
||||
/* Need to perform 4 passes on the images: */
|
||||
for (k = 0; k < 4; k++)
|
||||
for (j = InterlacedOffset[k];
|
||||
for (j = InterlacedOffset[k];
|
||||
j < SavedHeight;
|
||||
j += InterlacedJumps[k]) {
|
||||
if (EGifPutLine(GifFileOut,
|
||||
sp->RasterBits + j * SavedWidth,
|
||||
if (EGifPutLine(GifFileOut,
|
||||
sp->RasterBits + j * SavedWidth,
|
||||
SavedWidth) == GIF_ERROR)
|
||||
return (GIF_ERROR);
|
||||
}
|
||||
|
16
third_party/giflib/lib/quantize.c
vendored
16
third_party/giflib/lib/quantize.c
vendored
@ -129,7 +129,7 @@ GifQuantizeBuffer(unsigned int Width,
|
||||
free((char *)ColorArrayEntries);
|
||||
return GIF_ERROR;
|
||||
}
|
||||
if (NewColorMapSize < *ColorMapSize) {
|
||||
if ((int)NewColorMapSize < *ColorMapSize) {
|
||||
/* And clear rest of color map: */
|
||||
for (i = NewColorMapSize; i < *ColorMapSize; i++)
|
||||
OutputColorMap[i].Red = OutputColorMap[i].Green =
|
||||
@ -138,7 +138,7 @@ GifQuantizeBuffer(unsigned int Width,
|
||||
|
||||
/* Average the colors in each entry to be the color to be used in the
|
||||
* output color map, and plug it into the output color map itself. */
|
||||
for (i = 0; i < NewColorMapSize; i++) {
|
||||
for (i = 0; i < (int)NewColorMapSize; i++) {
|
||||
if ((j = NewColorSubdiv[i].NumEntries) > 0) {
|
||||
QuantizedColor = NewColorSubdiv[i].QuantizedColors;
|
||||
Red = Green = Blue = 0;
|
||||
@ -149,9 +149,9 @@ GifQuantizeBuffer(unsigned int Width,
|
||||
Blue += QuantizedColor->RGB[2];
|
||||
QuantizedColor = QuantizedColor->Pnext;
|
||||
}
|
||||
OutputColorMap[i].Red = (Red << (8 - BITS_PER_PRIM_COLOR)) / j;
|
||||
OutputColorMap[i].Green = (Green << (8 - BITS_PER_PRIM_COLOR)) / j;
|
||||
OutputColorMap[i].Blue = (Blue << (8 - BITS_PER_PRIM_COLOR)) / j;
|
||||
OutputColorMap[i].Red = (GifByteType)((Red << (8 - BITS_PER_PRIM_COLOR)) / j);
|
||||
OutputColorMap[i].Green = (GifByteType)((Green << (8 - BITS_PER_PRIM_COLOR)) / j);
|
||||
OutputColorMap[i].Blue = (GifByteType)((Blue << (8 - BITS_PER_PRIM_COLOR)) / j);
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ SubdivColorMap(NewColorMapType * NewColorSubdiv,
|
||||
/* Sort all elements in that entry along the given axis and split at
|
||||
* the median. */
|
||||
SortArray = (QuantizedColorType **)malloc(
|
||||
sizeof(QuantizedColorType *) *
|
||||
sizeof(QuantizedColorType *) *
|
||||
NewColorSubdiv[Index].NumEntries);
|
||||
if (SortArray == NULL)
|
||||
return GIF_ERROR;
|
||||
@ -235,14 +235,14 @@ SubdivColorMap(NewColorMapType * NewColorSubdiv,
|
||||
SortArray[j] = QuantizedColor;
|
||||
|
||||
/*
|
||||
* Because qsort isn't stable, this can produce differing
|
||||
* Because qsort isn't stable, this can produce differing
|
||||
* results for the order of tuples depending on platform
|
||||
* details of how qsort() is implemented.
|
||||
*
|
||||
* We mitigate this problem by sorting on all three axes rather
|
||||
* than only the one specied by SortRGBAxis; that way the instability
|
||||
* can only become an issue if there are multiple color indices
|
||||
* referring to identical RGB tuples. Older versions of this
|
||||
* referring to identical RGB tuples. Older versions of this
|
||||
* sorted on only the one axis.
|
||||
*/
|
||||
qsort(SortArray, NewColorSubdiv[Index].NumEntries,
|
||||
|
Loading…
Reference in New Issue
Block a user