@@ -13,7 +13,7 @@ void Global_Application::Close(void)
1313
1414 if (m_Texture) { m_Texture.reset (); m_Texture = nullptr ; }
1515
16- if (Render->NormalState () && DXTexture ) { DXTexture-> Release (); DXTexture = nullptr ; }
16+ if (Render->NormalState () && m_DXTexture ) { m_DXTexture. reset () ; }
1717
1818 m_Palette = 0 ;
1919
@@ -57,11 +57,9 @@ void Global_Application::ResetTexture(void)
5757
5858 if (Render->NormalState ())
5959 {
60- if (DXTexture) { DXTexture-> Release (); }
60+ m_DXTexture. reset (Render-> CreateTexture (m_Texture, m_Palette, Texture (). TransparencyFlags (), Texture (). TransparencyColor ()));
6161
62- DXTexture = Render->CreateTexture (m_Texture, m_Palette, Texture ().TransparencyFlags (), Texture ().TransparencyColor ());
63-
64- DXTexture->GetLevelDesc (0 , &m_TextureDesc);
62+ m_DXTexture->GetLevelDesc (0 , &m_TextureDesc);
6563 }
6664 }
6765 else { Close (); }
@@ -106,7 +104,7 @@ void Global_Application::Search(std::filesystem::path Filename)
106104 This->m_ProgressBar = 0 .0f ;
107105 This->b_Searching = true ;
108106
109- SearchModalCb = [&](float Progress, bool & b_Status) -> void
107+ This-> SearchModalCb = [&](float Progress, bool & b_Status) -> void
110108 {
111109 This->m_ProgressBar = Progress;
112110 b_Status = This->b_Searching ;
@@ -122,7 +120,7 @@ void Global_Application::Search(std::filesystem::path Filename)
122120
123121 External->Str .hWnd = This->Window ->Get ();
124122
125- External->Search (Filename, 0 , SearchModalCb, OnSearchCompleteCb);
123+ External->Search (Filename, 0 , This-> SearchModalCb , OnSearchCompleteCb);
126124 });
127125
128126 SearchModalFunc = [This]() -> void { This->SearchModal (); };
@@ -190,13 +188,13 @@ void Global_Application::MovePalette(std::uint16_t iPalette, bool Right)
190188void Global_Application::CopyPalette (void )
191189{
192190 if (!m_Texture) { return ; }
193- Texture ().CopyPalette (ClipboardPalette , m_Palette);
191+ Texture ().CopyPalette (m_ClipboardPalette , m_Palette);
194192}
195193
196194void Global_Application::PastePalette (void )
197195{
198- if (!m_Texture || ClipboardPalette .empty ()) { return ; }
199- if (Texture ().PastePalette (ClipboardPalette , m_Palette)) { b_RequestTextureReset = true ; }
196+ if (!m_Texture || m_ClipboardPalette .empty ()) { return ; }
197+ if (Texture ().PastePalette (m_ClipboardPalette , m_Palette)) { b_RequestTextureReset = true ; }
200198}
201199
202200void Global_Application::AddPalette (void )
@@ -378,6 +376,7 @@ void Global_Application::TextureIO(std::filesystem::path Filename, ImageIO Flags
378376#endif
379377
380378 bool b_KnownFileExt = false ;
379+ !b_KnownFileExt ? b_KnownFileExt = (m_FileExt == L" .TM2" ) ? true : false : false ;
381380 !b_KnownFileExt ? b_KnownFileExt = (m_FileExt == L" .TIM" ) ? true : false : false ;
382381 !b_KnownFileExt ? b_KnownFileExt = (m_FileExt == L" .CLT" ) ? true : false : false ;
383382 !b_KnownFileExt ? b_KnownFileExt = (m_FileExt == L" .PXL" ) ? true : false : false ;
@@ -391,6 +390,8 @@ void Global_Application::TextureIO(std::filesystem::path Filename, ImageIO Flags
391390
392391 if ((!b_KnownFileExt || b_DefaultFileType) && !b_Import && !b_Write && !b_SaveAs && !b_SaveAll) { m_PostSearchSelectedFile = 0 ; Search (Filename); return ; }
393392
393+ if ((m_FileExt == L" .TM2" ) && b_SaveAs) { Str.Message (L" I/O Error: TIM2 output is not yet supported" ); return ; }
394+
394395 if (b_SaveAll)
395396 {
396397 if (!b_SupportedSaveType) { Str.Message (L" I/O Error: cannot save all as unknown file type" ); return ; }
@@ -444,7 +445,7 @@ void Global_Application::TextureIO(std::filesystem::path Filename, ImageIO Flags
444445#ifdef LIB_JPEG
445446 if (std::to_underlying (SaveAllType) & std::to_underlying (ImageType::JPG))
446447 {
447- std::make_unique<Sony_PlayStation_Texture>(This->m_Filename , (size_t )This->File ()[iCnt].first )->SaveJPG (
448+ std::make_unique<Sony_PlayStation_Texture>(This->m_Filename , (size_t )This->File ()[iCnt].first )->SaveJPEG (
448449 Directory / This->Str .FormatCStyle (L" %ws_%04d_0x%08llx.jpg" , This->m_Filename .stem ().wstring ().c_str (), iCnt, This->File ()[iCnt].first ), NULL , iPalette, b_Truncate);
449450 }
450451#endif
@@ -493,7 +494,7 @@ void Global_Application::TextureIO(std::filesystem::path Filename, ImageIO Flags
493494 if (m_FileExt == L" .PNG" && !External->SavePNG (Filename, pSource, iPalette, b_Truncate)) { return ; }
494495#endif
495496#ifdef LIB_JPEG
496- if ((m_FileExt == L" .JPG" || m_FileExt == L" .JPEG" ) && !External->SaveJPG (Filename, pSource, iPalette, b_Truncate)) { return ; }
497+ if ((m_FileExt == L" .JPG" || m_FileExt == L" .JPEG" ) && !External->SaveJPEG (Filename, pSource, iPalette, b_Truncate)) { return ; }
497498#endif
498499
499500 if (b_OpenOnComplete)
@@ -517,6 +518,7 @@ void Global_Application::TextureIO(std::filesystem::path Filename, ImageIO Flags
517518
518519 External->Str .hWnd = Window->Get ();
519520
521+ if (m_FileExt == L" .TM2" && !External->OpenTIM2 (Filename, pSource, b_Palette, b_Pixel)) { return ; }
520522 if (m_FileExt == L" .TIM" && !External->OpenTIM (Filename, pSource, b_Palette, b_Pixel)) { return ; }
521523 if (m_FileExt == L" .CLT" && !External->OpenCLT (Filename, pSource)) { return ; }
522524 if (m_FileExt == L" .PXL" && !External->OpenPXL (Filename, pSource)) { return ; }
@@ -527,7 +529,7 @@ void Global_Application::TextureIO(std::filesystem::path Filename, ImageIO Flags
527529 if (m_FileExt == L" .PNG" && !External->OpenPNG (Filename, pSource)) { return ; }
528530#endif
529531#ifdef LIB_JPEG
530- if ((m_FileExt == L" .JPG" || m_FileExt == L" .JPEG" ) && !External->OpenJPG (Filename, pSource)) { return ; }
532+ if ((m_FileExt == L" .JPG" || m_FileExt == L" .JPEG" ) && !External->OpenJPEG (Filename, pSource)) { return ; }
531533#endif
532534
533535 if (!b_Palette) { External->DeletePalette (NULL , true ); }
@@ -581,7 +583,7 @@ void Global_Application::TextureIO(std::filesystem::path Filename, ImageIO Flags
581583 return ;
582584 }
583585
584- std::vector<Sony_Texture_16bpp > Palette = Texture ().ConvertPalette (External->GetPalette (), External->GetPaletteColorMax (), Texture ().GetPaletteColorMax ());
586+ std::vector<Sony_Pixel_16bpp > Palette = Texture ().ConvertPalette (External->GetPalette (), External->GetPaletteColorMax (), Texture ().GetPaletteColorMax ());
585587
586588 if (b_PaletteAdd)
587589 {
@@ -688,9 +690,9 @@ void Global_Application::TextureIO(ImageIO Flags, std::uintmax_t pSource, std::u
688690 {
689691 if (auto Filename = Window->GetOpenFilename (
690692 { L" All files" ,
691- L" Sony Texture Image" , L" Sony Texture CLUT" , L" Sony Texture Pixels" , L" Sony Bitstream" ,
693+ L" Sony Texture Image" , L" Sony Texture CLUT" , L" Sony Texture Pixels" , L" Sony Bitstream" , L" Sony Texture Image 2 " ,
692694 L" Bitmap Graphic" , L" Microsoft RIFF Palette" , L" Portable Network Graphics" , L" Joint Photographic Experts Group" },
693- { L" *.*" , L" *.tim" , L" *.clt" , L" *.pxl" , L" *.bs" , L" *.bmp" , L" *.pal" , L" *.png" , L" *.jpg;*.jpeg" }
695+ { L" *.*" , L" *.tim" , L" *.clt" , L" *.pxl" , L" *.bs" , L" *.tm2 " , L" *. bmp" , L" *.pal" , L" *.png" , L" *.jpg;*.jpeg" }
694696 ); Filename.has_value ())
695697 { TextureIO (Filename.value (), Flags, pSource, iPalette, SaveAllType); }
696698 }
0 commit comments