49 if (char_32_ptr ==
NULL) {
53 while (char_32_ptr[++len]);
62 for (; (*pch1) != 0 && (*pch2) != 0; pch1++, pch2++) {
63 if ((*pch1) != (*pch2)) {
64 return (*pch1) - (*pch2);
83 if (new_str ==
NULL) {
86 memcpy(new_str, str32, len *
sizeof(*str32));
92 unsigned char *CubeUtils::GetImageData(
IMAGE *img,
int left,
93 int top,
int wid,
int hgt) {
95 if (left < 0 || top < 0 || wid < 0 || hgt < 0 ||
102 unsigned char *temp_buff =
new unsigned char[wid * hgt];
103 if (temp_buff ==
NULL) {
110 for (
int y = 0, off = 0; y < hgt ; y++) {
112 for (
int x = 0; x < wid; x++, off++) {
113 temp_buff[off] = line.pixels[x] ? 255 : 0;
125 unsigned char *temp_buff = GetImageData(img, left, top, wid, hgt);
126 if (temp_buff ==
NULL) {
141 unsigned char *temp_buff = GetImageData(pix, left, top, wid, hgt);
142 if (temp_buff ==
NULL) {
157 if (char_samp ==
NULL) {
162 int stride = char_samp->
Stride(),
163 wid = char_samp->
Width(),
164 hgt = char_samp->
Height();
166 unsigned char *buff = char_samp->
RawData();
178 if (img->
create(wid, hgt, 1) == -1) {
187 for (
int y = 0, off = 0; y < hgt ; y++, off += stride) {
188 for (
int x = 0; x < wid; x++) {
189 line.
pixels[x] = (buff[off + x] == 0) ? 0 : 1;
201 if (char_samp ==
NULL) {
206 int stride = char_samp->
Stride();
207 int wid = char_samp->
Width();
208 int hgt = char_samp->
Height();
210 Pix *pix = pixCreate(wid, hgt, 1);
216 unsigned char *line = char_samp->
RawData();
217 for (
int y = 0; y < hgt ; y++, line += stride) {
218 for (
int x = 0; x < wid; x++) {
220 pixSetPixel(pix, x, y, 0);
222 pixSetPixel(pix, x, y, 255);
231 unsigned char *CubeUtils::GetImageData(Pix *pix,
int left,
int top,
234 if (left < 0 || top < 0 || wid < 0 || hgt < 0 ||
235 (left + wid) > pix->w || (top + hgt) > pix->h ||
241 unsigned char *temp_buff =
new unsigned char[wid * hgt];
242 if (temp_buff ==
NULL) {
253 pixGetDimensions(pix, &w, &h, &d);
254 wpl = pixGetWpl(pix);
255 data = pixGetData(pix);
256 line = data + (top * wpl);
258 for (
int y = 0, off = 0; y < hgt ; y++) {
259 for (
int x = 0; x < wid; x++, off++) {
260 temp_buff[off] = GET_DATA_BIT(line, x + left) ? 0 : 255;
270 FILE *fp = fopen(file_name.c_str(),
"rb");
276 fseek(fp, 0, SEEK_END);
277 int file_size = ftell(fp);
283 str->reserve(file_size);
286 char *buff =
new char[file_size];
291 int read_bytes = fread(buff, 1, static_cast<int>(file_size), fp);
292 if (read_bytes == file_size) {
293 str->append(buff, file_size);
297 return (read_bytes == file_size);
302 const string &delims,
303 vector<string> *str_vec) {
305 if (delims[0] !=
'\0' && delims[1] ==
'\0') {
307 const char* p = str.data();
308 const char* end = p + str.size();
313 const char* start = p;
314 while (++p != end && *p != c);
315 str_vec->push_back(
string(start, p - start));
321 string::size_type begin_index, end_index;
322 begin_index = str.find_first_not_of(delims);
323 while (begin_index != string::npos) {
324 end_index = str.find_first_of(delims, begin_index);
325 if (end_index == string::npos) {
326 str_vec->push_back(str.substr(begin_index));
329 str_vec->push_back(str.substr(begin_index, (end_index - begin_index)));
330 begin_index = str.find_first_not_of(delims, end_index);
337 int len = strlen(utf8_str);
339 for (
int ch = 0; ch < len; ch += step) {
342 UNICHAR uni_ch(utf8_str + ch, step);
351 for (
const char_32 *ch_32 = utf32_str; (*ch_32) != 0; ch_32++) {
362 bool all_one_case =
true;
375 first_upper = isupper(str32[0]);
376 first_lower = islower(str32[0]);
379 prev_upper = first_upper;
380 prev_lower = islower(str32[0]);
381 for (
int c = 1; str32[c] != 0; ++c) {
382 cur_upper = isupper(str32[c]);
383 cur_lower = islower(str32[c]);
384 if ((prev_upper && cur_lower) || (prev_lower && cur_upper))
385 all_one_case =
false;
388 prev_upper = cur_upper;
389 prev_lower = cur_lower;
398 prev_upper = first_upper;
401 for (
int c = 1; c <
StrLen(str32); ++c) {
404 if ((prev_upper && cur_lower) || (prev_lower && cur_upper))
405 all_one_case =
false;
408 prev_upper = cur_upper;
409 prev_lower = cur_lower;
412 return all_one_case || capitalized;
424 for (
int i = 0; i < len; ++i) {
426 if (ch == INVALID_UNICHAR_ID) {
435 if (!str32_lower ||
StrLen(str32_lower) != 1) {
439 lower[i] = str32_lower[0];
457 for (
int i = 0; i < len; ++i) {
459 if (ch == INVALID_UNICHAR_ID) {
468 if (!str32_upper ||
StrLen(str32_upper) != 1) {
472 upper[i] = str32_upper[0];