bool Andu::AnduMeshReader::Read( Caca::Mesh* pMesh, QString filePath ) { QFileInfo fio(filePath); if(fio.suffix() == "mesh") { Caca::MeshReader mReader; mReader.Read(pMesh, filePath); } else if(fio.suffix() == "obj") { AnduObjReader objReader; objReader.ReadIt(filePath); Caca::Mesh *pReadedMesh = objReader.Mesh(); for(int i = 0; i < pReadedMesh->GetSubMeshCount(); i++) { Caca::SubMesh* pSubMesh = pReadedMesh->GetSubMesh(i); pMesh->AddSubMesh(pSubMesh); } for(int i = 0; i < pMesh->GetSubMeshCount(); i++) { pReadedMesh->DeleteSubMesh(pMesh->GetSubMesh(i)); } } MeshToolbox::resetSkinningVertexToInit(pMesh); for(int i = 0; i < pMesh->GetSubMeshCount(); i++) { Caca::SubMesh* pSM = pMesh->GetSubMesh(i); WriteLog(QString("mesh: %1 vertexes in submesh %2 loaded").arg( pSM->GetVertexCount()).arg(i)); } return true; }
int handle_decode_arguments(char **argv, Images &images, int quality, int scale) { char *ext = strrchr(argv[1],'.'); if (!check_compatible_extension(ext)) { e_printf("Error: expected \".png\", \".pnm\" or \".pam\" file name extension for output file\n"); return 1; } FILE *file = fopen(argv[0],"rb"); if(!file) return 1; FileIO fio(file, argv[0]); if (!flif_decode(fio, images, quality, scale)) return 3; if (scale>1) v_printf(3,"Downscaling output: %ux%u -> %ux%u\n",images[0].cols(),images[0].rows(),images[0].cols()/scale,images[0].rows()/scale); if (images.size() == 1) { if (!images[0].save(argv[1],scale)) return 2; } else { int counter=0; std::vector<char> vfilename(strlen(argv[1])+6); char *filename = &vfilename[0]; strcpy(filename,argv[1]); char *a_ext = strrchr(filename,'.'); for (Image& image : images) { sprintf(a_ext,"-%03d%s",counter++,ext); if (!image.save(filename,scale)) return 2; v_printf(2," (%i/%i) \r",counter,(int)images.size()); v_printf(4,"\n"); } } v_printf(2,"\n"); return -1; }
bool encode_flif(int argc, char **argv, Images &images, int palette_size, int acb, flifEncodingOptional method, int lookback, int learn_repeats, int frame_delay, int divisor=CONTEXT_TREE_COUNT_DIV, int min_size=CONTEXT_TREE_MIN_SUBTREE_SIZE, int split_threshold=CONTEXT_TREE_SPLIT_THRESHOLD, int yiq=1, int plc=1) { bool flat=true; for (Image &image : images) if (image.uses_alpha()) flat=false; if (flat && images[0].numPlanes() == 4) { v_printf(2,"Alpha channel not actually used, dropping it.\n"); for (Image &image : images) image.drop_alpha(); } bool grayscale=true; for (Image &image : images) if (image.uses_color()) grayscale=false; if (grayscale && images[0].numPlanes() == 3) { v_printf(2,"Chroma not actually used, dropping it.\n"); for (Image &image : images) image.drop_color(); } uint64_t nb_pixels = (uint64_t)images[0].rows() * images[0].cols(); std::vector<std::string> desc; if (nb_pixels > 2) { // no point in doing anything for 1- or 2-pixel images if (plc) desc.push_back("PLC"); // compactify channels if (yiq) desc.push_back("YIQ"); // convert RGB(A) to YIQ(A) desc.push_back("BND"); // get the bounds of the color spaces } if (palette_size < 0) { palette_size = 1024; if (nb_pixels * images.size() / 2 < 1024) palette_size = nb_pixels * images.size() / 2; } if (palette_size > 0) desc.push_back("PLA"); // try palette (including alpha) if (palette_size > 0) desc.push_back("PLT"); // try palette (without alpha) if (acb == -1) { // not specified if ACB should be used if (nb_pixels * images.size() > 10000) desc.push_back("ACB"); // try auto color buckets on large images } else if (acb) desc.push_back("ACB"); // try auto color buckets if forced if (method.o == Optional::undefined) { // no method specified, pick one heuristically if (nb_pixels * images.size() < 10000) method.encoding=flifEncoding::nonInterlaced; // if the image is small, not much point in doing interlacing else method.encoding=flifEncoding::interlaced; // default method: interlacing } if (images.size() > 1) { desc.push_back("DUP"); // find duplicate frames desc.push_back("FRS"); // get the shapes of the frames if (lookback != 0) desc.push_back("FRA"); // make a "deep" alpha channel (negative values are transparent to some previous frame) } if (learn_repeats < 0) { // no number of repeats specified, pick a number heuristically learn_repeats = TREE_LEARN_REPEATS; if (nb_pixels * images.size() < 5000) learn_repeats--; // avoid large trees for small images if (learn_repeats < 0) learn_repeats=0; } FILE *file = fopen(argv[0],"wb"); if (!file) return false; FileIO fio(file, argv[0]); return flif_encode(fio, images, desc, method.encoding, learn_repeats, acb, frame_delay, palette_size, lookback, divisor, min_size, split_threshold); }
void data1() { hidemouse(); Panel modify; modify.init(6,56,getmaxx()-5,getmaxy()-7,THIN,IN);; modify.show(); modify.shape("MODIFY"); Panel move; move.init(220,120,525,455,OUT,THIN); move.show( ); move.shape("MODIFY"); showmouse(); settextstyle(0,0,1); ifstream fio("pro//product",ios::app); ofstream file("pro//temp",ios::out); fio.seekg(0); product s1,s2; int rno; char found='f'; char confirm='y'; outtextxy(240,202,"enter prno to append"); boxx(rno,240,222); while(!fio.eof()) { fio.read((char*)&s1,sizeof(product)); if(s1.no()==rno) { found='t'; if(confirm=='y') { s1.display(); s2.appm(s1); file.write((char*)&s2,sizeof(product));} confirm='n'; } else file.write((char*)&s1,sizeof(product)); } if(found=='f') outtextxy(240,242,"record not found"); fio.close(); file.close(); remove("pro//product"); rename("pro//temp","pro//product"); fio.close(); file.close(); }
bool decode_flif(char **argv, Images &images, flif_options &options) { FILE *file = NULL; if (!strcmp(argv[0],"-")) file = stdin; else file = fopen(argv[0],"rb"); if(!file) return false; FileIO fio(file, (file==stdin ? "from standard input" : argv[0])); metadata_options md; md.icc = options.color_profile; md.xmp = options.metadata; md.exif = options.metadata; return flif_decode(fio, images, options, md); }
void tdelete() { ifstream fio("pro//product",ios::app); ofstream file("pro//temp",ios::out); fio.seekg(0); int rno; char found='f'; char confirm='n'; outtextxy(240,202,"enter prno to be deleted"); boxx(rno,240,222); int vas=0; while(!fio.eof()) { fio.read((char*)&s1,sizeof(product)); if(s1.no()==rno) { found='t'; s1.display(); outtextxy(240,322," want to del this file(y/n) "); if(vas==0) confirm=getch(); char aop[1]={NULL}; sprintf(aop,"%c",confirm); outtextxy(240,342,aop); vas++; if(confirm=='n') { file.write((char*)&s1,sizeof(product));} } else file.write((char*)&s1,sizeof(product)); }//eow if(found=='f') outtextxy(240,242,"record not found"); fio.close(); file.close(); remove("pro//product"); rename("pro//temp","pro//product"); fio.close(); file.close(); }
doctorChangeDialog::doctorChangeDialog( QWidget *parent, doctor* doc ) : doc(doc), QDialog(parent) { ui.setupUi(this); QByteArray fio(doc->fio), dolgnost(doc->dolgnost), work(doc->priem); //QTextCodec *codec = QTextCodec::codecForName("Windows-1251"); QTextCodec *codec = QTextCodec::codecForName("CP866"); QString fioString = codec->toUnicode(fio); QString dolgnostString = codec->toUnicode(dolgnost); QString workString = codec->toUnicode(work); ui.fio->setText( fioString ); ui.cabinet->setText( QString::number( doc->cabinet ) ); ui.speciality->setText( dolgnostString ); ui.workHours->setText( workString ); }
void GPSstuff(char *filename) { #if GPSDEBUG printf("GPS starting...\n"); #endif //CommDevice GPS("COM1", 0, 115200, 128); GPS = new CommDevice("COM1", 0, 115200, 180); #if GPSDEBUG printf("GPS successfully started...\n"); #endif GPS->Write("em,,/msg/nmea/RMC:.2\n"); //fio << "Hello world" << endl; vector<smGPSDatum> GPStars; char templocGPSbuf[360]; smGPSDatum tempsmGPS; char prevmode = mode; while (!escape) { //printf("Switching modes...\n"); fstream fio(filename); if (!fio.is_open()) { printf("Error: unable to open %s\n", filename); } //load the target GPSs if (mode == AUTOMODE) { //printf("auto mode\n (GPS)\n"); while(!fio.eof()) { //printf("loading target...\n"); smGPSDatum smtemp; if (loadGPStar(&smtemp, &fio)) { printf("Loaded Target: Lat: %2.12f, Lon: %3.12f\n", smtemp.latitude, smtemp.longitude); GPStars.insert(GPStars.begin(), smtemp); } } printf("%d GPS targets loaded.\n", GPStars.size()); } SetEvent(hTargetsLoaded); while (!escape) { if (mode != prevmode) { prevmode = mode; break; } //find terminating null-character char *tc = strchr(templocGPSbuf, 0); char *GPSToParse = 0; #if FORCEGPSINPUT GPSToParse = new char[256]; sprintf(GPSToParse, "$GNRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W,N*6A"); #else //DWORD evstatus; //do //{ // WaitCommEvent(GPS.hComm, &evstatus, NULL); //} while (evstatus != EV_RXFLAG); //printf("starting GPS read\n"); GPS->Read(tc); //GPS.Read(rawGPSdata, sizeof(rawGPSdata)); int i; //char *GPSEnd = 0; for (i = strlen(tc)/*256*/; i > 0 && tc[i] != '\n'; --i); if (tc[i] == '\n') { //printf("\\n at i=%d\n", i); //GPSEnd = &tc[i]; //tc[i] = 0; for ( ; i > 0 && tc[i] != '$'; --i); if (tc[i] == '$') { GPSToParse = &tc[i]; //printf("GPSToParse: %s\n", GPSToParse); } } #endif if (GPSToParse) { //strcpy(strrchr(locGPSbuf, 0), rawGPSdata); #if GPSDEBUG if (rawGPSdata) printf("GPS: %s\n", rawGPSdata); else printf("Error: rawGPSdata == 0\n"); #endif //printf("rawGPSdata: %s\n", rawGPSdata); //printf("Going to parse GPS...\n"); //printf("GPSToParse: %s\n", GPSToParse); char *cur_pos = strstr(GPSToParse, "$GNRMC"); //printf("cur_pos: %s\n", cur_pos); if (cur_pos)//strstr(rawGPSdata, "$GNRMC")) { //Parse the GPS data from rawGPSdata //Look for GPS coordinates, etc: //char *cur_pos; unsigned char i = 0; //shoud always be less than 255 commas //printf("looking for a value for cur_pos\n"); cur_pos = strchr(cur_pos, ',');//strchr(rawGPSdata, ','); GPSDatum curGPS = {0}; //printf("cur_pos: %d\n", cur_pos); while (cur_pos) { double tempd; cur_pos = strchr(cur_pos, ','); if (cur_pos) { cur_pos++; switch(++i) { case 1: //UTC Time [char*] memcpy(curGPS.time, cur_pos, 6); #if GPSDEBUG printf("time: %s\n", curGPS.time); #endif break; case 2: //Status (A = Active, V = Void) [char] curGPS.status = (cur_pos && *cur_pos != ',') ? *cur_pos : 0; #if GPSDEBUG printf("status: %c\n", curGPS.status); #endif if (tolower(curGPS.status) != 'a') { //force a break from the loop cur_pos = 0; } break; case 3: //Latitude [double] //must convert from DDMM.MMM to DD.DDDD tempd = atof(cur_pos+2); curGPS.latitude = ((atof(cur_pos) - tempd)/100.0 + tempd/60.0); //curGPS.latitude = atof(cur_pos); break; case 4: //Latitude N/S [char] curGPS.latitudeNS = (cur_pos && *cur_pos != ',') ? *cur_pos : 0; if (tolower(curGPS.latitudeNS) == 's') { curGPS.latitude *= -1.0; } //#if GPSDEBUG printf("latitude: %f\n", curGPS.latitude); //#endif break; case 5: //Longitude [double] //must convert from DDMM.MMM to DD.DDDD tempd = atof(cur_pos+3); curGPS.longitude = ((atof(cur_pos) - tempd)/100.0 + tempd/60.0); //curGPS.longitude = atof(cur_pos); break; case 6: //Longitude E/W [char] curGPS.longitudeEW = (cur_pos && *cur_pos != ',') ? *cur_pos : 0; if (tolower(curGPS.longitudeEW) == 'w') { curGPS.longitude *= -1.0; } //#if GPSDEBUG printf("longitude: %f\n", curGPS.longitude); //#endif break; case 7: //Velocity (knots) [float] curGPS.velocity = (float)atof(cur_pos); #if GPSDEBUG printf("velocity: %f\n", curGPS.velocity); #endif break; case 8: //Heading True North [float] curGPS.heading = (float)atof(cur_pos); #if GPSDEBUG printf("heading: %f\n", curGPS.heading); #endif break; case 9: //UTC Date [char*] memcpy(curGPS.date, cur_pos, 6); #if GPSDEBUG printf("date: %s\n", curGPS.date); #endif break; case 10: //Magnetic Variation [float] curGPS.magvariation = (float)atof(cur_pos); #if GPSDEBUG printf("magvariation: %f\n", curGPS.magvariation); #endif break; case 11: //Magnetic Variation E/W [char] curGPS.magvariationEW = (cur_pos && *cur_pos != ',') ? *cur_pos : 0; if (tolower(curGPS.magvariationEW) == 'e') { curGPS.magvariation *= -1.0; } #if GPSDEBUG printf("magvariationEW: %c\n", curGPS.magvariationEW); #endif break; case 12: //Checksum [char*] memcpy(curGPS.checksum, cur_pos, 4); #if GPSDEBUG printf("checksum: %s\n", curGPS.checksum); #endif break; } } } if (curGPS.checksum[1] != '*') { printf("continuing...\n\a"); goto mylab; //perhaps there is a more elegant way to fix this (?) //continue; //continue; did not seem to work } if (mode != GPSMODE) { WaitForSingleObject(mStoreGPS, INFINITE); if (StoreGPS) { smGPSDatum savetempGPSDatum; savetempGPSDatum.latitude = curGPS.latitude; savetempGPSDatum.longitude = curGPS.longitude; saveGPStar(&savetempGPSDatum, &fio); //store the current GPS location at this point in the code StoreGPS = false; printf("GPS Stored!\n"); SetEvent(hStoreGPS); //currently unusued; perhaps later to stop robot until GPS point recorded } ReleaseMutex(mStoreGPS); } else { //it is auto mode printf("GPStars.size(): %d\n", GPStars.size()); if (curGPSHit) { if (GPStars.size()) { tempsmGPS = GPStars.back(); printf("New GPS Target: Lat: %f, Long: %f\n", tempsmGPS.latitude, tempsmGPS.longitude); GPStars.pop_back(); curGPSHit = 0; } else { //all GPS targets have been reached, or no GPS targets remain printf("Done.\n"); stopmain = true; } } GPSvector tempGPSvec = getvector(&curGPS, &tempsmGPS); tempGPSvec.curdir = curGPS.heading; tempGPSvec.magvariation = curGPS.magvariation; WaitForSingleObject(mGPSData, INFINITE); //curGPSHit = false; curGPSvec = tempGPSvec; //CompassData = atof(rawGPSdata)/10; //copy to global compass value here ReleaseMutex(mGPSData); SetEvent(hNewGPSData); } } } mylab: char tempstr[256]; strcpy(tempstr, tc); memset(templocGPSbuf, 0, sizeof(templocGPSbuf)); strcpy(templocGPSbuf, tempstr); } fio.close(); } }
bool decode_flif(char **argv, Images &images, int quality, int scale, int resize_width, int resize_height) { FILE *file = fopen(argv[0],"rb"); if(!file) return false; FileIO fio(file, argv[0]); return flif_decode(fio, images, quality, scale, resize_width, resize_height); }
bool encode_flif(int argc, char **argv, Images &images, flif_options &options) { bool flat=true; unsigned int framenb=0; for (Image& i : images) { i.frame_delay = options.frame_delay[framenb]; if (framenb+1 < options.frame_delay.size()) framenb++; } for (Image &image : images) if (image.uses_alpha()) flat=false; if (flat && images[0].numPlanes() == 4) { v_printf(2,"Alpha channel not actually used, dropping it.\n"); for (Image &image : images) image.drop_alpha(); } bool grayscale=true; for (Image &image : images) if (image.uses_color()) grayscale=false; if (grayscale && images[0].numPlanes() == 3) { v_printf(2,"Chroma not actually used, dropping it.\n"); for (Image &image : images) image.drop_color(); } uint64_t nb_pixels = (uint64_t)images[0].rows() * images[0].cols(); std::vector<std::string> desc; if (nb_pixels > 2) { // no point in doing anything for 1- or 2-pixel images if (options.plc && (images[0].getDepth() > 8 || !options.loss)) { desc.push_back("Channel_Compact"); // compactify channels (not if lossy, because then loss gets magnified!) } if (options.ycocg) { desc.push_back("YCoCg"); // convert RGB(A) to YCoCg(A) } desc.push_back("PermutePlanes"); // permute RGB to GRB desc.push_back("Bounds"); // get the bounds of the color spaces } // only use palette/CB if we're lossless, because lossy and palette don't go well together... if (options.palette_size == -1) { options.palette_size = DEFAULT_MAX_PALETTE_SIZE; if (nb_pixels * images.size() / 3 < DEFAULT_MAX_PALETTE_SIZE) { options.palette_size = nb_pixels * images.size() / 3; } } if (!options.loss && options.palette_size != 0) { desc.push_back("Palette_Alpha"); // try palette (including alpha) desc.push_back("Palette"); // try palette (without alpha) } if (!options.loss) { if (options.acb == -1) { // not specified if ACB should be used if (nb_pixels * images.size() > 10000) { desc.push_back("Color_Buckets"); // try auto color buckets on large images } } else if (options.acb) { desc.push_back("Color_Buckets"); // try auto color buckets if forced } } if (options.method.o == Optional::undefined) { // no method specified, pick one heuristically if (nb_pixels * images.size() < 10000) options.method.encoding=flifEncoding::nonInterlaced; // if the image is small, not much point in doing interlacing else options.method.encoding=flifEncoding::interlaced; // default method: interlacing } if (images.size() > 1) { desc.push_back("Duplicate_Frame"); // find duplicate frames if (!options.loss) { // only if lossless if (options.frs) desc.push_back("Frame_Shape"); // get the shapes of the frames if (options.lookback) desc.push_back("Frame_Lookback"); // make a "deep" alpha channel (negative values are transparent to some previous frame) } } if (options.learn_repeats < 0) { // no number of repeats specified, pick a number heuristically options.learn_repeats = TREE_LEARN_REPEATS; //if (nb_pixels * images.size() < 5000) learn_repeats--; // avoid large trees for small images if (options.learn_repeats < 0) options.learn_repeats=0; } bool result = true; if (!options.just_add_loss) { FILE *file = NULL; if (!strcmp(argv[0],"-")) file = stdout; else file = fopen(argv[0],"wb"); if (!file) return false; FileIO fio(file, (file == stdout? "to standard output" : argv[0])); if (!flif_encode(fio, images, desc, options)) result = false; } else { BlobIO bio; // will just contain some unneeded FLIF header stuff if (!flif_encode(bio, images, desc, options)) result = false; else if (!images[0].save(argv[0])) result = false; } // get rid of palette images[0].clear(); return result; }
MessageRef ReadZipFile(const char * fileName, bool loadData) { FileDataIO fio(muscleFopen(fileName, "rb")); return ReadZipFile(fio, loadData); }
status_t WriteZipFile(const char * fileName, const Message & msg, int compressionLevel, uint64 fileCreationTime) { FileDataIO fio(muscleFopen(fileName, "wb")); return WriteZipFile(fio, msg, compressionLevel, fileCreationTime); }
bool encode_flif(int argc, char **argv, Images &images, int palette_size, int acb, flifEncodingOptional method, int lookback, int learn_repeats, std::vector<int> &frame_delay, int divisor=CONTEXT_TREE_COUNT_DIV, int min_size=CONTEXT_TREE_MIN_SUBTREE_SIZE, int split_threshold=CONTEXT_TREE_SPLIT_THRESHOLD, int yiq=1, int plc=1, int frs=1, int cutoff=2, int alpha=19, int crc_check=-1, int loss=0) { bool flat=true; unsigned int framenb=0; for (Image& i : images) { i.frame_delay = frame_delay[framenb]; if (framenb+1 < frame_delay.size()) framenb++; } for (Image &image : images) if (image.uses_alpha()) flat=false; if (flat && images[0].numPlanes() == 4) { v_printf(2,"Alpha channel not actually used, dropping it.\n"); for (Image &image : images) image.drop_alpha(); } bool grayscale=true; for (Image &image : images) if (image.uses_color()) grayscale=false; if (grayscale && images[0].numPlanes() == 3) { v_printf(2,"Chroma not actually used, dropping it.\n"); for (Image &image : images) image.drop_color(); } uint64_t nb_pixels = (uint64_t)images[0].rows() * images[0].cols(); std::vector<std::string> desc; if (nb_pixels > 2) { // no point in doing anything for 1- or 2-pixel images if (plc && !loss) { desc.push_back("Channel_Compact"); // compactify channels (not if lossy, because then loss gets magnified!) } if (yiq) { desc.push_back("YCoCg"); // convert RGB(A) to YCoCg(A) } desc.push_back("Bounds"); // get the bounds of the color spaces } if (!loss) { // only use palette/CB if we're lossless, because lossy and palette don't go well together... if (palette_size == -1) { palette_size = 1024; if (nb_pixels * images.size() / 2 < 1024) { palette_size = nb_pixels * images.size() / 2; } } if (palette_size != 0) { desc.push_back("Palette_Alpha"); // try palette (including alpha) } if (palette_size != 0) { desc.push_back("Palette"); // try palette (without alpha) } if (acb == -1) { // not specified if ACB should be used if (nb_pixels * images.size() > 10000) { desc.push_back("Color_Buckets"); // try auto color buckets on large images } } else if (acb) { desc.push_back("Color_Buckets"); // try auto color buckets if forced } } if (method.o == Optional::undefined) { // no method specified, pick one heuristically if (nb_pixels * images.size() < 10000) method.encoding=flifEncoding::nonInterlaced; // if the image is small, not much point in doing interlacing else method.encoding=flifEncoding::interlaced; // default method: interlacing } if (images.size() > 1) { desc.push_back("Duplicate_Frame"); // find duplicate frames if (!loss) { // only if lossless if (frs) desc.push_back("Frame_Shape"); // get the shapes of the frames if (lookback) desc.push_back("Frame_Lookback"); // make a "deep" alpha channel (negative values are transparent to some previous frame) } } if (learn_repeats < 0) { // no number of repeats specified, pick a number heuristically learn_repeats = TREE_LEARN_REPEATS; if (nb_pixels * images.size() < 5000) learn_repeats--; // avoid large trees for small images if (learn_repeats < 0) learn_repeats=0; } FILE *file = fopen(argv[0],"wb"); if (!file) return false; FileIO fio(file, argv[0]); return flif_encode(fio, images, desc, method.encoding, learn_repeats, acb, palette_size, lookback, divisor, min_size, split_threshold, cutoff, alpha, crc_check, loss); }
bool handle_encode_arguments(int argc, char **argv, Images &images, int palette_size, int acb, flifEncodingOptional method, int lookback, int learn_repeats, int frame_delay) { int nb_input_images = argc-1; while(argc>1) { Image image; v_printf(2,"\r"); if (!image.load(argv[0])) { e_printf("Could not read input file: %s\n", argv[0]); return 2; }; images.push_back(std::move(image)); const Image& last_image = images.back(); if (last_image.rows() != images[0].rows() || last_image.cols() != images[0].cols() || last_image.numPlanes() != images[0].numPlanes()) { e_printf("Dimensions of all input images should be the same!\n"); e_printf(" First image is %ux%u, %i channels.\n",images[0].cols(),images[0].rows(),images[0].numPlanes()); e_printf(" This image is %ux%u, %i channels: %s\n",last_image.cols(),last_image.rows(),last_image.numPlanes(),argv[0]); return 2; } argc--; argv++; if (nb_input_images>1) {v_printf(2," (%i/%i) ",(int)images.size(),nb_input_images); v_printf(4,"\n");} } v_printf(2,"\n"); bool flat=true; for (Image &image : images) if (image.uses_alpha()) flat=false; if (flat && images[0].numPlanes() == 4) { v_printf(2,"Alpha channel not actually used, dropping it.\n"); for (Image &image : images) image.drop_alpha(); } uint64_t nb_pixels = (uint64_t)images[0].rows() * images[0].cols(); std::vector<std::string> desc; desc.push_back("YIQ"); // convert RGB(A) to YIQ(A) desc.push_back("BND"); // get the bounds of the color spaces if (palette_size > 0) desc.push_back("PLA"); // try palette (including alpha) if (palette_size > 0) desc.push_back("PLT"); // try palette (without alpha) if (acb == -1) { // not specified if ACB should be used if (nb_pixels > 10000) desc.push_back("ACB"); // try auto color buckets on large images } else if (acb) desc.push_back("ACB"); // try auto color buckets if forced if (method.o == Optional::undefined) { // no method specified, pick one heuristically if (nb_pixels < 10000) method.encoding=flifEncoding::nonInterlaced; // if the image is small, not much point in doing interlacing else method.encoding=flifEncoding::interlaced; // default method: interlacing } if (images.size() > 1) { desc.push_back("DUP"); // find duplicate frames desc.push_back("FRS"); // get the shapes of the frames if (lookback != 0) desc.push_back("FRA"); // make a "deep" alpha channel (negative values are transparent to some previous frame) } if (learn_repeats < 0) { // no number of repeats specified, pick a number heuristically learn_repeats = TREE_LEARN_REPEATS; if (nb_pixels < 5000) learn_repeats--; // avoid large trees for small images if (learn_repeats < 0) learn_repeats=0; } FILE *file = fopen(argv[0],"wb"); if (!file) return false; FileIO fio(file, argv[0]); return flif_encode(fio, images, desc, method.encoding, learn_repeats, acb, frame_delay, palette_size, lookback); }