@@ -207,7 +207,7 @@ bool load_from_file(void* sd, const char* file_path, const char* schedule)
207207 return false ;
208208};
209209
210- uint8_t * txt2img (void * sd, const sd_txt2img_options* opt, int64_t * output_size )
210+ const char * txt2img (void * sd, const sd_txt2img_options* opt)
211211{
212212 const auto sm = std::string (opt->sample_method );
213213 const auto it = SampleMethodMap.find (sm);
@@ -224,16 +224,16 @@ uint8_t* txt2img(void* sd, const sd_txt2img_options* opt, int64_t* output_size)
224224 /* int sample_steps */ opt->sample_steps ,
225225 /* int64_t seed */ opt->seed
226226 );
227- *output_size = static_cast < int64_t > (result. size () );
228- const auto buffer = new uint8_t [result .size ()];
229- std::memcpy (buffer, result. data (), result .size ());
227+ const auto str=code::base64_encode<std::string,std::vector< uint8_t >> (result, false );
228+ const auto buffer = new char [str .size ()];
229+ std::memcpy (buffer, str. c_str (), str .size ());
230230 return buffer;
231231 }
232232 delete opt;
233233 return nullptr ;
234234};
235235
236- uint8_t * img2img (void * sd, const sd_img2img_options* opt, int64_t * output_size )
236+ const char * img2img (void * sd, const sd_img2img_options* opt)
237237{
238238 const auto sm = std::string (opt->sample_method );
239239 const auto it = SampleMethodMap.find (sm);
@@ -253,10 +253,11 @@ uint8_t* img2img(void* sd, const sd_img2img_options* opt, int64_t* output_size)
253253 /* float strength */ opt->strength ,
254254 /* int64_t seed */ opt->seed
255255 );
256- *output_size = static_cast < int64_t > (result. size () );
257- const auto buffer = new uint8_t [result .size ()];
258- std::memcpy (buffer, result. data (), result .size ());
256+ const auto str=code::base64_encode<std::string,std::vector< uint8_t >> (result, false );
257+ const auto buffer = new char [str .size ()];
258+ std::memcpy (buffer, str. c_str (), str .size ());
259259 return buffer;
260+
260261 }
261262 delete opt;
262263 return nullptr ;
@@ -276,12 +277,12 @@ const char* get_stable_diffusion_system_info()
276277{
277278 const std::string info = sd_get_system_info ();
278279 const size_t length = info.size () + 1 ;
279- char * buffer = new char [length];
280+ const auto buffer = new char [length];
280281 std::memcpy (buffer, info.c_str (), length);
281282 return buffer;
282283};
283284
284- void free_buffer (const uint8_t * buffer)
285+ void free_buffer (const char * buffer)
285286{
286287 delete [] buffer;
287288}
0 commit comments