public virtual object dropEvent(object @event) { if (@event.mimeData().hasUrls) { @event.setDropAction(QtCore.Qt.CopyAction); @event.accept(); // to get a list of files: var drop_list = new List <object>(); foreach (var url in @event.mimeData().urls()) { drop_list.append(str(url.toLocalFile())); } // handle the list here foreach (var f in drop_list) { try { if (!f.endswith(".cbr") && !f.endswith(".cbz") && !f.endswith(".zip") && !f.endswith(".rar")) { Image.open(f); } shutil.copy(f, this._tmpinputfolder); } catch { } } } else { @event.ignore(); } }
public static object resizeImage( object path, object sizeX, object sizeY, object state, object secondFilePath) { var size = Tuple.Create(sizeX, sizeY); var resizedImage = Image.@new("RGB", size, Tuple.Create(0, 0, 0)); var image1 = Image.open(path).convert("RGB"); image1.thumbnail(size); var _tup_1 = image1.size; var width1 = _tup_1.Item1; var height1 = _tup_1.Item2; if (state != 0 && secondFilePath != "") { var image2 = Image.open(secondFilePath).convert("RGB"); image2.thumbnail(size); var _tup_2 = image2.size; var width2 = _tup_2.Item1; var height2 = _tup_2.Item2; if (state == 1) { resizedImage.paste(image1, Tuple.Create(Convert.ToInt32(sizeX / 2 - width1), Convert.ToInt32((sizeY - height1) / 2))); resizedImage.paste(image2, Tuple.Create(Convert.ToInt32(sizeX / 2), Convert.ToInt32((sizeY - height2) / 2))); } else { resizedImage.paste(image2, Tuple.Create(Convert.ToInt32(sizeX / 2 - width2), Convert.ToInt32((sizeY - height2) / 2))); resizedImage.paste(image1, Tuple.Create(Convert.ToInt32(sizeX / 2), Convert.ToInt32((sizeY - height1) / 2))); } } else { resizedImage.paste(image1, Tuple.Create(Convert.ToInt32((sizeX - width1) / 2), Convert.ToInt32((sizeY - height1) / 2))); } return(resizedImage); }