JeViCo Posted December 29, 2022 Share Posted December 29, 2022 Side by side comparsion of 20x20 info icon: *Click here* Example code: local iconPath = "info.png" local f = fileOpen(iconPath) local rawData = fileRead(f, fileGetSize(f)) fileClose(f) local pathTex = dxCreateTexture(iconPath) local rawDataTex = dxCreateTexture(rawData) local size = 20 addEventHandler("onClientRender", root, function() dxDrawImage(0, 0, size, size, pathTex) -- texture created from path (the left one) dxDrawImage(size, 0, size, size, rawDataTex) -- texture created from raw data (the right one) end) Does anyone know how to fix this? Link to comment
Shady1 Posted December 29, 2022 Share Posted December 29, 2022 37 minutes ago, JeViCo said: Side by side comparsion of 20x20 info icon: *Click here* Example code: local iconPath = "info.png" local f = fileOpen(iconPath) local rawData = fileRead(f, fileGetSize(f)) fileClose(f) local pathTex = dxCreateTexture(iconPath) local rawDataTex = dxCreateTexture(rawData) local size = 20 addEventHandler("onClientRender", root, function() dxDrawImage(0, 0, size, size, pathTex) -- texture created from path (the left one) dxDrawImage(size, 0, size, size, rawDataTex) -- texture created from raw data (the right one) end) Does anyone know how to fix this? hello! @JeViCo welcome to forum,set mipmap option to false element dxCreateTexture ( string pixels / string filepath [, string textureFormat = "argb", bool mipmaps = true, string textureEdge = "wrap" ] ) https://wiki.multitheftauto.com/wiki/DxCreateTexture Link to comment
JeViCo Posted December 29, 2022 Author Share Posted December 29, 2022 Changing mipmaps or textureEdge arguments doesn't do much (using mipmaps = false & textureEdge = clamp) *click* Link to comment
Shady1 Posted December 29, 2022 Share Posted December 29, 2022 Can you send the icon you use, I want to review (image) Link to comment
JeViCo Posted December 29, 2022 Author Share Posted December 29, 2022 (edited) Sure https://www.dropbox.com/s/4pjz59zhur3dzfg/info_icon.png I looks OK on 1920x1080 resolution however it looks too bad on higher res Edited December 29, 2022 by JeViCo Link to comment
Shady1 Posted December 29, 2022 Share Posted December 29, 2022 1 hour ago, JeViCo said: Sure https://www.dropbox.com/s/4pjz59zhur3dzfg/info_icon.png I looks OK on 1920x1080 resolution however it looks too bad on higher res Hello again @JeViCoI did some research and here's what I have to say : The picture may be getting corrupted because you are reading it as a string,it might be losing bit depth,Why don't you read this as a file? Link to comment
JeViCo Posted January 10, 2023 Author Share Posted January 10, 2023 (edited) I'm trying to protect my assets. I don't want to make them public/reusable for someone Is there any way to fix it? Maybe i should preprocess textures idk Edited January 10, 2023 by JeViCo Link to comment
Shady1 Posted January 10, 2023 Share Posted January 10, 2023 (edited) <script src="blabla.lua" type="client" cache="false"/> Scripts are preserved with "cache" a player can take a screenshot and edit the picture thanks to photoshop and get it,but if you want to keep your lua scripts use cache tag in meta.xml Edited January 10, 2023 by Shady1 Link to comment
JeViCo Posted January 20, 2023 Author Share Posted January 20, 2023 I'm not sure that this is the answer i was expecting but still, thanks. I'll probably open an issue on GitHub later on Link to comment
Mobin Posted January 21, 2023 Share Posted January 21, 2023 10 hours ago, JeViCo said: I'm not sure that this is the answer i was expecting but still, thanks. I'll probably open an issue on GitHub later on after you created your texture it saves your pixels in memory then you can just delete your texture file with `fileDelete` but your clients have to download your texture file always when they are trying to connect to server ------ local path = "img.png"; if fileExists(path) then local texture = dxCreateTexture(path); fileDelete(path); end ------ but why you are trying to do that? i think imgs and sounds are not important that much but your code is your client can extract that image with just taking an screenshot with this you torture both your client and yourself Link to comment
JeViCo Posted January 23, 2023 Author Share Posted January 23, 2023 On 21/01/2023 at 11:54, Mobin said: but why you are trying to do that? Quick example 1: I drew a whole gta map from scratch all by myself and put a lot of effort into it Quick example 2: I drew a set of unique liveries for vehicles and i don't want them to be anywhere else Link to comment
Mobin Posted January 23, 2023 Share Posted January 23, 2023 4 hours ago, JeViCo said: Quick example 1: I drew a whole gta map from scratch all by myself and put a lot of effort into it Quick example 2: I drew a set of unique liveries for vehicles and i don't want them to be anywhere else i can't find other ways for that only way is loading texture by file path `dxCreateTexture("img.png")` to let cpp load that file you can delete the file after you loaded that but it happens when script loaded if player download the img and left the server before it loads the client can save that file at other place Link to comment
Moderators IIYAMA Posted January 23, 2023 Moderators Share Posted January 23, 2023 @JeViCo Just wondering if cutting the process in smaller parts would give you the same effect (you never know): local width, height = dxGetPixelsSize ( rawData ) local rawDataTex = dxCreateTexture(width, height) dxSetTexturePixels (rawDataTex, rawData) 1 Link to comment
DiSaMe Posted January 26, 2023 Share Posted January 26, 2023 Maybe this has something to do with non-power-of-2 dimensions? If so, then 16x16 or 32x32 would give a better result than 20x20. I don't see an obvious reason why it would be like that, since if it can properly load the data coming from a file, it should be able to load the same data coming from a string. But it all depends on what's happening inside dxCreateTexture. I guess there might be some indirection involved, like drawing the texture to a buffer and then reading it to produce the final texture, which could degrade the quality for non-power-of-2 textures. 1 Link to comment
JeViCo Posted January 26, 2023 Author Share Posted January 26, 2023 On 24/01/2023 at 02:12, IIYAMA said: @JeViCo Just wondering if cutting the process in smaller parts would give you the same effect (you never know): local width, height = dxGetPixelsSize ( rawData ) local rawDataTex = dxCreateTexture(width, height) dxSetTexturePixels (rawDataTex, rawData) Nah. It seems to be a texture size-related issue 5 hours ago, Reyomin said: Maybe this has something to do with non-power-of-2 dimensions? If so, then 16x16 or 32x32 would give a better result than 20x20. I don't see an obvious reason why it would be like that, since if it can properly load the data coming from a file, it should be able to load the same data coming from a string. But it all depends on what's happening inside dxCreateTexture. I guess there might be some indirection involved, like drawing the texture to a buffer and then reading it to produce the final texture, which could degrade the quality for non-power-of-2 textures. Technically we found the solution to the problem of this topic. Thank you for great explanation Texture is stretching somewhere and actual problem hides somewhere deep in the source code. Any furher code-related discussion will be placed on Github Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now