: WARNING - support of the decompiler is now VERY LIMITED. There are no active developers. This means waiting times in the issue tracker are very long and mostly depend on community. Sorry for the inconvenience.

List of issuesList of issues

#1199 Automatically import alpha channel do JPEG3 and JPEG4 tags from PNG.
Author: user Jinxed_K
Date created:
Type: feature
Visibility: Everybody
Assigned to: developer honfika
Labels: Images
State: upgraded Help

> What steps will reproduce the problem? - Open .swf file - Click 'images' on tree in resource mode - Right click on image in right hand side window and click replace - Replace with desired image (PNG in this case) - Image doesn't retain transparency (Or appears to be totally transparent) and doesn't show up once in game Looking at the image info in Hex dump mode Image tag is DefineBitsJPEG3, the original has bitmapAlphaData, but any image inserted there loses the data. Extracting the original image shows it is a PNG with transparency. Inserting a JPG in the same ID makes it show up but no transparency. > What is the expected output? What do you see instead? See above > What version of the product are you using? Is it "nightly build"? Which operating system do you have? JPEXS: v8.0.1 release OS: Windows 8.1 > Please provide any additional information below. If the problem is related to a SWF file, attach it here, otherwise we can't help you. Honestly, I am a beginner at flash and only looking to replace images in an existing flash file. Please let me know if this is just user error.
developer
This is true, when you import an image, it will import only the image data, not the bitmapAlphaData. You can import the alpha channel with a separate button. This button is not in the context menu, you should select the image. For this you need a binary file which contains only the alpha bytes. So width*height bytes, no header or anything. (As it is in the hex view) Ok, I know that it is not so user friendly so I'll change this issue to a feature request. The alpha channel should be imported automatically from PNGs to JPEG3 and JPEG4 tags (after a confirmation message)
Title: PNG losing transparency when replacing images→Automatically import alpha channel do JPEG3 and JPEG4 tags from PNG.
Type: bug→feature
developer
State: new→opened
Assigned:developer honfika
developer
Please try the latest nightly. Now you can import the alpha channel from a png file with the "Replace alpha channel" button. If you import a png (or gif) to the image data, then the png bytes will be added to the imagedata field, bitmapalphadata should be empty.
State: opened→upgraded
user
Tried out the build, but I don't understand what I'm supposed to do. I replaced the image with a png I wanted I see the replace alpha channel button but no matter what I try and import from that button, it fails with 'invalid alpha channel data' Do I import the same png? Do I need to convert it to something else? (This part I never understood. The binary file originally mentioned was something that escaped me as well)
developer
Now you can import 2 types of mask file. 1st, which was already implemented earlier should contain exactly (width*height) bytes where width is the with of our image, height is the height of your image 2nd: import any image which can be opened by java, the image should have the same size as the image in the tag The alpha channel values will be imported from the selected image (all other image data will be ignored) You can import the alpha channel only if the image in the tag is JPEG. If it is a png/gif, you can't have separated alpha data, since the image already has it. Could you please copy the exception message from the log window (click on the right bottom icon)
user
Ok, I understand what I'm supposed to do now. I was under the impression that importing a PNG into the JPEG3 tagged entry would import the transparency from the PNG as well. I've imported a JPG and then manually imported the alpha channel info from a PNG of the same image and it worked as expected. No exception message was generated when I did it correctly.
developer
But if you import only the transparent PNG (but no another alpha mask) it should also work. Since JPEG3/4 and tag supports PNG anf GIF also.
user
Nightly Build 1384 When I tried to import a transparent PNG into the JPEG3 tagged entry, the preview shows fine in JPEXS but when I use the file in the game, the whole image is invisible. It does not give an exception message and takes the image just fine. When I look at the hex dump, it gives an error though. 21/03/2016 20:01:12 SEVERE Uncaught exception in thread: AWT-EventQueue-0 java.lang.NullPointerException at com.jpexs.decompiler.flash.tags.DefineBitsLossless2Tag.getImage(DefineBitsLossless2Tag.jav a:258) at com.jpexs.decompiler.flash.tags.base.ImageTag.getImage(ImageTag.java:116) at com.jpexs.decompiler.flash.gui.MainPanel.showPreview(MainPanel.java:3160) at com.jpexs.decompiler.flash.gui.MainPanel.valueChanged(MainPanel.java:2889) at javax.swing.JTree.fireValueChanged(Unknown Source) at javax.swing.JTree$TreeSelectionRedirector.valueChanged(Unknown Source) at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(Unknown Source) at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(Unknown Source) at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(Unknown Source) at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(Unknown Source) at javax.swing.JTree.setSelectionPath(Unknown Source) at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(Unknown Source) at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(Unknown Source) at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(Unknown Source) at java.awt.AWTEventMulticaster.mousePressed(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
developer
Please attach your swf and the image you wanted to import + a step by step guide to reproduce the problem. In the exception the problem is in a lossless2 image tag not in a jpeg3 image tag.
user
Just FYI, I`m having the same issue. I can provide my files if you want.
developer
Ok, please provide you files. Thanks.
user
Thank you for your kindness. The thing I was working on is about changing several images in an existing flash file. File I attached are the ones I was working on. I tried to change image 151 in 'Hud_lib.swf' file with 'image 136.png'. It looks fine on the JPEXS using replace feature, but when I check in game, it`s all transparent, probably due to alpha related error.
Downloadimage 136.png (8 KiB)Downloadhud_lib.swf (743 KiB)
developer
But your hud_lib.swf already contains the image you attached, when I replace it, the result is exactly the same as the original swf. So I doin't think that it is wrong if the original is working.... They are the same.
developer
Or maybe you attached a wrong hud_lib.swf... which was already replaced with ffdec.
developer
You can try to convert your image to jpeg. Replace image tag 151 with the jpeg Then select the tag, press "Replace alpha channel..." button, and select the png file In this case the jpgeg3 tag will contain a jpeg image + alpha channel data.
developer
+Could you please try the latest nightly with PNG (as earlier)?
user
I tried like you told me which is to convert png to jpeg and then replace alpha channel. Unfortunately it crashes the game itself when I put that file. I worked with nightly 1388(newest). I`m sorry that I attached the file I was working on last night. New 'hud_lib' I attached one is the original.
Downloadhud_lib.swf (479 KiB)
developer
Can you tell me how to reproduce the problem? Because this is only a lib swf, nothing happens whne i start it.. Could you please try to reproduce the problem on a standalone swf?
developer
So this 2 attached files are both wrong, right?
user
Yes. 'png_wrong' lose it`s data and bounds turn to [0x0]. 'jpeg_wrong' looks fine via JPEXS, but when I turn on the game it crashes while loading. I`m sorry that I can`t make it a standalone since I`m a newbie about making swf. FYI game I`m working on is 'world of warships' which are notorious about editing swf files so I understand.
developer
How do you know that the bounds turns to 0x0? In this case we have to wait the files from Jinxed_K, because when I change an image in our test swf to PNG, it works. Maybe there is check in the loader, in this case you won't be able to replace anything. (Or you have to patch the loader)
user
Sorry it took a while to respond. I wanted to test this out thoroughly before posting again, but didn't have time till this weekend. I'm actually trying to edit the same file that Nanasaki_Koko is from the same game... Using Nightly Build 1390 Steps to reproduce - Open hud_lib.swf - open 'images' tree - Image #151 icon_shell_he_normal is what I want to replace - replace with image HE.png using 'replace' button on the right pane - load game, icon is invisible as shown in attached screenshot pngreplace.jpg - reopen original hud_lib.swf - open 'images' tree - replace with image HE.jpg using 'replace' button on the right pane - replace alpha channel with image HE.png using 'replace alpha channel' button on the right pane - load game, icon works (artifacts in image is my image quality issue) as shown in attached screenshot jpgreplace.jpg This replace also works in the commandline with the following and only needs the png image. ffdec.bat -replace hud_lib.swf hud_lib_new.swf 151 HE.png lossless2
Downloadpngreplace.jpg (16 KiB)Downloadjpgreplace.jpg (18 KiB)Downloadhud_lib.swf (479 KiB)DownloadHE.png (5 KiB)DownloadHE.jpg (2 KiB)
developer
- load game how?
developer
Jinxed_K: Could you please try this file: hud_lib_png_wrong.swf? It was created in the same way as your second file. (Import jpeg + alpha from png).. but Nanasaki_Koko said that it is also wrong... I don't understand why.
developer
Sorry, i mean hud_lib_jpeg_wrong.swf, this should be ok.
user
Nanasaki's hud_lib_jpeg_wrong.swf works fine as is. The edited icon shows up.
DownloadNanasaki.jpg (16 KiB)
user
May be that my file created collision with other files since I have a bunch of modified swfs. I`m sorry about that. I should have checked more thoroughly...
 
Google Translate: Translate to Czech Translate to Slovak Translate to Russian Translate to Hungarian Translate to Swedish Translate to French Translate to German Translate to Spanish Translate to Italian
Change style: oceanic classic