Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private class ConvertCMYK extends AsyncTask<Void, Void, String>
- {
- private String url;
- private Bitmap original;
- private ImageInfo info;
- private MagickImage imageCMYK;
- private File imageFile;
- private AQuery aq;
- public ConvertCMYK(String url, Bitmap original, AQuery aq)
- {
- this.url = url;
- this.original = original;
- this.aq = aq;
- }
- @Override
- protected void onPreExecute()
- {
- aq.id(R.id.progress).visible();
- }
- @Override
- protected String doInBackground(Void... params)
- {
- try
- {
- imageFile = aq.getCachedFile(url);
- info = new ImageInfo(imageFile.getAbsolutePath());
- imageCMYK = new MagickImage(info);
- if(imageCMYK.getColorspace() == ColorspaceType.CMYKColorspace)
- {
- boolean imgConvertStatus = imageCMYK.transformRgbImage(ColorspaceType.CMYKColorspace);
- if(imgConvertStatus)
- {
- imageCMYK.setFileName(imageFile.getAbsolutePath());
- imageCMYK.writeImage(info);
- }
- else
- {
- throw new Exception();
- }
- }
- else
- {
- return null;
- }
- }
- catch(Exception e)
- {
- return null;
- }
- return "Executed";
- }
- @Override
- protected void onPostExecute(String result)
- {
- if(result != null)
- aq.id(R.id.photo).image(new File(imageFile.getAbsolutePath()), 350);
- else
- aq.id(R.id.photo).image(original, 0);
- aq.id(R.id.progress).gone();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement