value ImageGd (value img,value filename) { ImageData _img = getImage(img); FILE *_file = openFileWrite(filename); gdImageGd(imageImage(_img),_file); fclose(_file); return val_null; }
value ImageJpeg(value img,value filename,value quality) { int _quality = val_int(quality); ImageData _img = getImage(img); FILE *_file = openFileWrite(filename); gdImageJpeg(imageImage(_img),_file,_quality); fclose(_file); return val_null; }
value ImageGd2 (value img,value filename,value compressed,value chunksize) { ImageData _img = getImage(img); int _compressed = val_int(compressed); int _chunksize = val_int(chunksize); FILE *_file = openFileWrite(filename); gdImageGd2(imageImage(_img),_file,_chunksize,_compressed); fclose(_file); return val_null; }
void writePlaintextFile(Buffer const & buf, FileName const & fname, OutputParams const & runparams) { ofdocstream ofs; if (!openFileWrite(ofs, fname)) return; // make sure we are ready to export buf.updateBuffer(); buf.updateMacroInstances(OutputUpdate); writePlaintextFile(buf, ofs, runparams); }
int openStudentFile(FILE **fileRead, FILE **fileWrite) { if (openFileRead("data.txt", fileRead) == -1) { // if open file has error, then create the file if (openFileWrite("data.txt", fileWrite) == -1) { printf("Cannot create data.txt! Serious error! \n"); return -1; } else { printf("Created empty data.txt, because file did not exist\n"); fprintf(*fileWrite, "%s\t%s\t%s\t%s\t\n", "회원ID", "회원이름", "회원주소", "핸드폰번호"); fflush(*fileWrite); return 1; } } return 0; }
void PreviewLoader::Impl::startLoading(bool wait) { if (pending_.empty() || !pconverter_) return; // Only start the process off after the buffer is loaded from file. if (!buffer_.isFullyLoaded()) return; LYXERR(Debug::GRAPHICS, "PreviewLoader::startLoading()"); // As used by the LaTeX file and by the resulting image files string const directory = buffer_.temppath(); string const filename_base = unique_filename(directory); // Create an InProgress instance to place in the map of all // such processes if it starts correctly. InProgress inprogress(filename_base, pending_, pconverter_->to); // clear pending_, so we're ready to start afresh. pending_.clear(); // Output the LaTeX file. FileName const latexfile(filename_base + ".tex"); // we use the encoding of the buffer Encoding const & enc = buffer_.params().encoding(); ofdocstream of; try { of.reset(enc.iconvName()); } catch (iconv_codecvt_facet_exception const & e) { LYXERR0("Caught iconv exception: " << e.what() << "\nUnable to create LaTeX file: " << latexfile); return; } TexRow texrow; otexstream os(of, texrow); OutputParams runparams(&enc); LaTeXFeatures features(buffer_, buffer_.params(), runparams); if (!openFileWrite(of, latexfile)) return; if (!of) { LYXERR(Debug::GRAPHICS, "PreviewLoader::startLoading()\n" << "Unable to create LaTeX file\n" << latexfile); return; } of << "\\batchmode\n"; dumpPreamble(os); // handle inputenc etc. buffer_.params().writeEncodingPreamble(os, features); of << "\n\\begin{document}\n"; dumpData(of, inprogress.snippets); of << "\n\\end{document}\n"; of.close(); if (of.fail()) { LYXERR(Debug::GRAPHICS, "PreviewLoader::startLoading()\n" << "File was not closed properly."); return; } double const font_scaling_factor = buffer_.isExporting() ? 75.0 * buffer_.params().html_math_img_scale : 0.01 * lyxrc.dpi * lyxrc.zoom * lyxrc.preview_scale_factor; // FIXME XHTML // The colors should be customizable. ColorCode const bg = buffer_.isExporting() ? Color_white : PreviewLoader::backgroundColor(); ColorCode const fg = buffer_.isExporting() ? Color_black : PreviewLoader::foregroundColor(); // The conversion command. ostringstream cs; cs << pconverter_->command << " " << quoteName(latexfile.toFilesystemEncoding()) << " --dpi " << int(font_scaling_factor) << " --fg " << theApp()->hexName(fg) << " --bg " << theApp()->hexName(bg); // FIXME what about LuaTeX? if (buffer_.params().useNonTeXFonts) cs << " --latex=xelatex"; if (buffer_.params().encoding().package() == Encoding::japanese) cs << " --latex=platex"; if (buffer_.params().bibtex_command != "default") cs << " --bibtex=" << quoteName(buffer_.params().bibtex_command); else if (buffer_.params().encoding().package() == Encoding::japanese) cs << " --bibtex=" << quoteName(lyxrc.jbibtex_command); else cs << " --bibtex=" << quoteName(lyxrc.bibtex_command); if (buffer_.params().bufferFormat() == "lilypond-book") cs << " --lilypond"; string const command = libScriptSearch(cs.str()); if (wait) { ForkedCall call(buffer_.filePath()); int ret = call.startScript(ForkedProcess::Wait, command); static int fake = (2^20) + 1; int pid = fake++; inprogress.pid = pid; inprogress.command = command; in_progress_[pid] = inprogress; finishedGenerating(pid, ret); return; } // Initiate the conversion from LaTeX to bitmap images files. ForkedCall::SignalTypePtr convert_ptr(new ForkedCall::SignalType); convert_ptr->connect(bind(&Impl::finishedGenerating, this, _1, _2)); ForkedCall call(buffer_.filePath()); int ret = call.startScript(command, convert_ptr); if (ret != 0) { LYXERR(Debug::GRAPHICS, "PreviewLoader::startLoading()\n" << "Unable to start process\n" << command); return; } // Store the generation process in a list of all such processes inprogress.pid = call.pid(); inprogress.command = command; in_progress_[inprogress.pid] = inprogress; }