Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize design of standard image widget #325

Merged
merged 4 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/airunner/styles/dark_theme/main.qss
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ QTableWidget::item:selected {
background-color: @darkerprimary-color;
}

#standard_image_widget QPushButton,
#image_widget QPushButton {
border: 1px solid @darkerprimary-color;
}
Expand Down
1 change: 1 addition & 0 deletions src/airunner/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ def apply_opacity_to_image(image, target_opacity):
target_opacity = 255 * target_opacity
if target_opacity == 0:
target_opacity = 1
image = image.convert("RGBA")
r, g, b, a = image.split()
a = a.point(lambda i: target_opacity if i > 0 else 0)
image.putalpha(a)
Expand Down
1 change: 0 additions & 1 deletion src/airunner/widgets/canvas_plus/canvas_plus_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ def handle_outpaint(self, outpaint_box_rect, outpainted_image, action=None, is_k
new_image = Image.alpha_composite(new_image, new_image_b)
new_image = Image.alpha_composite(new_image, new_image_a)

new_image.save("test.png")
return new_image, image_root_point, image_pivot_point

def load_image_from_path(self, image_path):
Expand Down
19 changes: 10 additions & 9 deletions src/airunner/widgets/canvas_plus/standard_image_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from PIL import Image
from PIL import PngImagePlugin
from PIL.ImageQt import ImageQt

from airunner.widgets.canvas_plus.canvas_base_widget import CanvasBaseWidget
from airunner.widgets.canvas_plus.templates.standard_image_widget_ui import Ui_standard_image_widget
Expand All @@ -35,9 +36,10 @@ def __init__(self, *args, **kwargs):
self.ui.batch_container.hide()
self.ui.delete_confirmation.hide()
self.ui.tableWidget.hide()
self.ui.image_frame.hide()
self.ui.similar_groupbox.hide()

def handle_image_data(self, data):
print(data)
self.image_path = data["path"]
images = data["images"]
if len(images) == 1:
Expand All @@ -47,20 +49,17 @@ def handle_image_data(self, data):
self.load_batch_images(images)

def clear_batch_images(self):
for widget in self.ui.batch_container.layout().children():
for widget in self.ui.batch_container.findChildren(QLabel):
widget.deleteLater()

def load_batch_images(self, images):
self.ui.batch_container.show()
self.clear_batch_images()
images = images[:4]
for image in images:
raw_data = image.tobytes("raw", "RGBA")
qimage = QImage(
raw_data,
image.size[0],
image.size[1],
QImage.Format.Format_RGBA8888
)
# resize the image to 128x128
image = image.resize((128, 128))
qimage = ImageQt(image)
pixmap = QPixmap.fromImage(qimage)
label = QLabel()
label.setPixmap(pixmap)
Expand Down Expand Up @@ -140,6 +139,8 @@ def set_pixmap(self, image_path=None, image=None):
self.set_table_data(meta_data)

self.ui.controls_container.show()
self.ui.image_frame.show()
self.ui.similar_groupbox.show()

def handle_label_clicked(self, event):
# create a popup window and show the full size image in it
Expand Down
Loading