bluescan / tacentview

An image and texture viewer for tga, png, apng, exr, dds, pvr, ktx, ktx2, astc, pkm, qoi, gif, hdr, jpg, tif, ico, webp, and bmp files. Uses Dear ImGui, OpenGL, and Tacent. Useful for game devs as it displays information like the presence of an alpha channel and querying specific pixels for their colour.
ISC License
329 stars 32 forks source link

Ability to copy/ paste infomation from R/G/B/Alpha channel of an image in the viewer. #168

Closed quockhanhlk closed 2 months ago

quockhanhlk commented 3 months ago

The viewer currently already support viewing separate R/G/B/Alpha channel already, it would be such a huge improvement if it's possible to copy information from those channels to an external image editor (photoshop), and then paste the edited ones back into the image viewer ( for channel packing purposes - although photoshop or other image editors can do channel packing already, it would be great if the image viewer can also do this).

Great image viewer anyway, i really love it, thank you so much !

bluescan commented 3 months ago

Thanks for the kind words. Regaring the feature request I assume you mean copying specific channels of the entire canvas in one go (rather than one pixel at a time). Ctrl-C will copy the entire image (RGBA) to the clipboard (which can then be pasted in PS or whatever). I think what you're after is when you paste into Tacent View that you can either create a new image (what happens now), or optionally paste the data into the current image but only for specific channels?

quockhanhlk commented 3 months ago

Hi, and yes - copy specific channel of the entire canvas is what i mean. And when viewing one specific channel (RGBA) in Tacent view, it would be great if it's also possible to paste back the entire canvas into the channel that is currently being viewed/ isolated. Really sorry for the confusion!

quockhanhlk commented 3 months ago

I accidentally hit 'comment & close" the issue, sorry for that

bluescan commented 3 months ago

No worries. Yeah...something can be done about both of these. There's a little to think about though...if you're pasting rgb or rgba clipboard contents into a single channel, there is a question of the intent...r to r, g to g, etc, or perhaps intensity (average rgb) was intended. In any case, it's a good idea and shouldn't be too difficult ...when I next get some free time ;)

quockhanhlk commented 3 months ago

Hi, thank you for considering the feature request! To better describe the feature i think i should illustrate it with the intended workflow that i use:

To save on memory when shipping (some studios do this practice, some dont), 3 or 4 textures are packed together into one image. Usually this is done on the textures of a model in its final stage, but sometimes there is a need to adjust specific texture(s) that is already packed. This usually mean i have to open the texturing app, make the adjust, re export and repack the textures again. The intended use case with Tacent view is:

useCaseTacentView

example_marci_mask2

Again, thank you very much for considering!

bluescan commented 3 months ago

Thanks for the diagram. Current design is something like this (which will allow your workflow):

Add options for ctrl-c ctrl-v behaviour to the channels dialog:

Copy (Ctrl-C) Intensity will copy the R G B or A into an RGBA image on the clipboard (where R=G=B, A=1). Otherwise individual channels are copied to RGBA on the clipboard (R->R, G->G, etc). Default is RGBA all checked which will match current behaviour.

Unspecified channel colour (RGBA) picker : Used if NOT intensity mode AND at least one channel not selected. Default opaque black (a=1, rgb=0). This is the only GUI widget needed for Copy I think.

Paste (Ctrl-V) Combo dropdown: OptionA : Create new image (default and current behaviour). OptionB : Paste selected channels: Intensity will compute the clipboard RGB intensity and paste to the specific selected channel (including alpha). If non-intensity will paste only selected channels: R->R, G->G, B->B, A->A. If clipboard image has no alpha treat as 1.0.

If the edited image in your diagram is greyscale, it won't matter whether you select intensity/G or individual/G when pasting as Intensity = V*3/3 = V for greyscale... but it would allow multiple channels to be edited at once if desired.

The anchor would be the top left of image in case images are of different dimension. The current image/canvas size would not be modified, so pasting a larger image would discard pixels at right and bottom and pasting a smaller image would leave right and bottom pixels unmodified.

Not quite sure when I'll get to this (work got busy), but I'll probably do this as the next task as the other main effort is supporting wide-gamut 10-bit displays with is quite a bit more work ;)

quockhanhlk commented 3 months ago

This all sound great, thank you so much! I'll patiently wait so please feel no pressure on time.

bluescan commented 2 months ago

Copy is done. Paste will take a bit longer because it should be undo-able etc.

bluescan commented 2 months ago

This is all working in a498e47ae96e7b2efbfd6d65d0b2f4294c1773ef For convenience some of the related preferences are also displayed in the channel-filters:

image

The copy behaviour:

image

The paste behaviour:

image

You will need to turn off paste-creates-image.

bluescan commented 2 months ago

In case you don't have cmake installed: tacentview_1.0.44.zip

quockhanhlk commented 2 months ago

Hi, thank you very much for working on the request, i've tested the copy feature out and it works perfectly. The pasting feature is not working properly for me, it crash the program immediately when i hit ctrl V, whether 'paste creates image' is toggled on or off. Im currently using windows 11 if it help.

bluescan commented 2 months ago

Hmm. So I've tried pasting from Affinity Photo, GIMP 2.10, the Windows 11 Snipping Tool, and from TacentView. Does copying from the snipping tool allow you to paste into Tacent View? This might be hard to debug if I don't have the contents of the clipboard. I'm assuming you are using PhotoShop, which I don't have. Would be curious if it's only PS giving you issues.

quockhanhlk commented 2 months ago

Hi, upon further testing i think that is a specific problem with my version of PTS, im using a really old version (CC 2015) and it caused tacent view to crash when pasting. I've tried copy from snipping tool, from Krita and from web browser (firefox) and it works!

But there is still a problem, when pasting, the pasted image shifted a few pixels horizontally, this does not happen when copying and pasting from a channel to a different channel directly inside tacent view, but it happen when the pasted image is external (from Krita or from web browser).

i've included a video showcasing the bug:

https://github.com/bluescan/tacentview/assets/12829684/07fcb104-f44a-421f-9002-066008c532ed

bluescan commented 2 months ago

OK. I was able to repo by copying from Krita. Tacent View uses a 3rd party library called "Clip Library" to retrieve (and set) images in the clipboard. I've updated this library to latest and it seems to have fixed the issue. Give this new zip a go. You might also try pasting from your older PS again, but no guarantees ;)

tacentview_1.0.44.zip

quockhanhlk commented 2 months ago

Hi, its rare (and great) to caught up with you at around the same time! I've just tested the new build, pasting from krita is now perfect! But pasting from web browser is still having the same shifted pixels problem, although, copying from web might not be a popular workflow so you should judge if this is worth fixing. I'll stick to krita for now, thank you very much for the build !

Just in case, i was using firefox as web browser, and Imgur.com as image host, i also tried copying and pasting from photopea.com which is a web app photoshop clone, these 2 gave me the same shifted pixel bug.

bluescan commented 2 months ago

Hi quockhanhlk! I just tried a few more tests. Although I was getting slightly different results from you, I did manage to repo the crash by using photopea in chrome (in FF it wasn't copying to clipboard at all... but it's prolly some permission thing set wrong somewhere). In any case, I'm pretty sure I'm using the library incorrectly when pasting... and also think I know where I messed up. I need to rewrite some logic to support more types of image data from the clipboard. I think it is worth fixing the crash. I'll probably see if you're available for another test once that's done. Not sure ETA yet. (Incidentally, copy.pasting from FF did seem to work for me without the offset... but I think it's not worth worrying about until I fix the known issues).

quockhanhlk commented 2 months ago

I'll try to test build out as soon as i can when they're available. Current build works great with krita so no worry on ETA. Thank you for the effort!

bluescan commented 2 months ago

NP. Couldn't let it go. Here's another build. Thanks for testing and also no rush.

For me with this build I didn't see any offsets: Paste from FF works. Paste from Photopea in FF. Could not get to work (even pasting to Affinity or Krita). Paste from Photopea in Chrome. Worked, Would crash previously. Paste from Krita works. Paste from Affinity works.

If you try Photoshop again I'd be curious if the crash is gone. tacentview_1.0.44.zip

quockhanhlk commented 2 months ago

The crash is gone, now even my old version of PTS works perfectly. I've tried pasting from photopea using firefox, chrome, and edge, and unfortunately the offset bug is still persisted, so maybe this has something to do with my pc ?

Thank you anyway, this is great ! and this is non related but i think firefox default (or some ad blocking extension) is blocking copy/paste access from photopea, im not sure where that setting is exactly but that should be it.

bluescan commented 2 months ago

Thanks for testing. Glad to have removed a crash (with your help testing). IDK why you're getting the offset either (can't repo) but possibly some subtle bug in the clipping lib I'm using? In your vid it looked like the image was rolled 3 pixels to the left. Before closing this issue I've added a workaround that 'may' help:

image

Try putting in 3 in the first field... or adjust appropriately... and then paste from photopea. If it is a roll of the image, these values might help compensate (vertically and horizontally -- in opposite direction if negatives entered). You could even have different values for each viewer profile to easily allow switching (with Alt-1 or Alt-2).

tacentview_1.0.44.zip

quockhanhlk commented 2 months ago

Hey, thank you for the new build, that setting helps correct the pasting behavior from webpage i had. Thank you so much for working on this !

bluescan commented 2 months ago

NP. Thanks for testing!