Jump to content

guix

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by guix

  1. Hello, When I load a custom file, I parse it and get a string from it. Then I would like this string to appear in a textbox in the Save dialog... but no matter what I try, it doesn't work: I read the string from the file successfully, I can set the Title of the textbox, but not it's Value :S private enum PropertyNames { TextBox_ArrayName, } string arrayName = "array_name"; public override PropertyCollection OnCreateSavePropertyCollection() { List<Property> props = new List<Property> { new StringProperty(PropertyNames.TextBox_ArrayName, "array_name") }; return new PropertyCollection(props); } public override ControlInfo OnCreateSaveConfigUI(PropertyCollection props) { ControlInfo configUI = CreateDefaultSaveConfigUI(props); configUI.SetPropertyControlValue(PropertyNames.​TextBox_ArrayName, ControlInfoPropertyNames.DisplayName, "Give a name to the array:"); // I can do that to confirm that arrayName is successfully read from the the file: //configUI.SetPropertyControlValue(PropertyNames.​TextBox_ArrayName, ControlInfoPropertyNames.DisplayName, arrayName); //Doesn't work //PropertyControlInfo pci = configUI.FindControlForPropertyName(PropertyNames.​TextBox_ArrayName); //pci.Property.Value = arrayName; //Doesn't work //props[PropertyNames.​TextBox_ArrayName].Value = arrayName; return configUI; } protected override Document OnLoad(Stream input) { ... arrayName = "name_from_file"; ... } protected override void OnSaveT(Document input, Stream output, PropertyBasedSaveConfigToken token, Surface scratchSurface, ProgressEventHandler progressCallback) { ... arrayName = (string)token.GetProperty(PropertyNames.​TextBox_ArrayName).Value; ... } I have tried other things but no luck... What did I do wrong?
  2. Ok well I give up, the plugin wil not support loading. Thank you anyway
  3. Hello, I have an issue with a filetype plugin I am writing. I need to show a dialog with 2 textboxes when opening the file, and I will enter the size of the image in those textbox, because the size can't be found in the file (only raw pixel data). How could I do that ?
  4. How can I change the extension of the file when saving? For ex if encoding method 1 is used, set extension to ".xg1", etc... Is it possible?
  5. Sorry midora I don't understand what you said... But no problem, the code is still very fast, load/save speed isn't an issue at all. Meanwhile I have made a lot of progress, I have added an optional RLE-like algorithm (2 versions of it), this was easy to make and works quite well, sometimes produce a smaller file than equivalent 24bits PNG. Actually I'm making tests to see what is the best compromise filesize/code speed (these are images that will be loaded on a small TFT display controlled by an Arduino, I'm making a GUI library for it). But I would like to make an option "Autodetect" in the Save dialog, that will test some output modes (ex: with or without RLE v1, or v2...), and choose the one that makes a smaller file. Similar to the PNG Save dialog I guess. How can I do that, is it at least possible with plugins? Edit: auto detection done
  6. Hello again, Nice to know that we can save layers separately, even if I don't need it actually So I managed to make a plugin that can save and load the custom format, which is great news (actually, just RGBA8888 but I don't have problem converting from/to my custom format "RGBA5658") Basically: protected override Document OnLoad(Stream input) { // The 4 first bytes of the file are the size of the image in pixels UInt16 sizeX = (UInt16)( (input.ReadByte() << 8) | input.ReadByte() ); UInt16 sizeY = (UInt16)( (input.ReadByte() << 8) | input.ReadByte() ); Bitmap bmp = new Bitmap(sizeX, sizeY, PixelFormat.Format32bppArgb); for (int column = 0; column < sizeY; column++) { for (int row = 0; row < sizeX; row++) { byte r = (byte)input.ReadByte(); byte g = (byte)input.ReadByte(); byte b = (byte)input.ReadByte(); byte a = (byte)input.ReadByte(); bmp.SetPixel(row, column, Color.FromArgb((int)((a << 24) | (r << 16) | (g << 8) | ); } } return Document.FromImage(bmp); } protected override void OnSave(Document input, Stream output, SaveConfigToken token, Surface scratchSurface, ProgressEventHandler callback) { //BinaryWriter binWriter = new BinaryWriter(output); input.Flatten(scratchSurface); UInt16 sizeX = (UInt16)input.Width; UInt16 sizeY = (UInt16)input.Height; output.WriteByte((byte)(sizeX >> 8)); output.WriteByte((byte)(sizeX & 0xFF)); output.WriteByte((byte)(sizeY >> 8)); output.WriteByte((byte)(sizeY & 0xFF)); for (int row = 0; row < scratchSurface.Height; row++) { for (int column = 0; column < scratchSurface.Width; column++) { ColorBgra bgra = scratchSurface[column, row]; output.WriteByte(bgra.R); output.WriteByte(bgra.G); output.WriteByte(bgra.; output.WriteByte(bgra.A); //binWriter.Write( packRGBA8888(bgra.R, bgra.G, bgra.B, bgra.A) ); } } //binWriter.Dispose(); } It works well enough for now, I'm just wondering if there is a better/faster way of doing the Load(). Any tips? Also another questions: What is the difference between OnSave and OnSaveT ? Does scratchSurface.Height and scratchSurface.Width always equals input.Height and input.Width ? Thanks.
  7. Hello midora, thank you for this. At least a start, let me try some things Edit: I only did that for now as a quick test: output.WriteByte(bgra.R); output.WriteByte(bgra.G); output.WriteByte(bgra.; output.WriteByte(bgra.A); And it worked... I can't believe how easy it was (but I couldn't have done it without your code)
  8. Hello all, I need to make a FileExport plugin which export into a custom format, that is a binary file with 24 bits per pixel: 16 bits for RGB565 and 8bits for the alpha channel. No metadata, no header, just an array of bytes. The big problem is, I have absolutely no idea how to do this... I saw some sample plugins but they all look simple (even if I don't understand most of the code...), using things like: PixelFormat.Bgr565 or PixelFormats.Bgra32. Obviously my custom pixel format isn't in the list. For now, I just would like an example how to get pixels RGBA colors inside the OnSave(T?) callback. Then I can try myself to convert it to the format I need. And then I will probably come back here to ask other questions about how to actually write in the output file. You guessed, I am totally lost... Any help appreciated!
  9. I solved the errors and made it compile, but being new to C# and never used bitmap etc functions, I'm lost at what to do next... I will ask few questions in the development forum.
  10. Have you tried it? Because it doesn't even compile. It's almost 6 years old. After hours of searching I finally found a source code of another export plugin, it compiled and worked. But it didn't help a lot since what I want to do is totally different, which is why I would like the source code of this particular plugin since it is almost exactly what I want to do: export an array of RGB565, but with an additional byte for each pixel, that is the pixel's transparency.
  11. Hello, any chance that you share the source code? I would like to write a custom export format but I need some example plugin. Thanks!
  12. One week later, almost 200 views and not a single reply, this forum is useless.
  13. Hello all, I have a problem with a font in PDN. The font work normally in Photoshop, but in PDN it doesn't. The font is called HelveticaNeueBd.ttf. I tried to download it from 2 different websites, here is one: https://bedita.googlecode.com/svn-history/r1379/trunk/vendors/phpThumb/fonts/HelveticaNeueBd.ttf Here is how it appears in PDN's font browser: So, the V letter is working...but that's about it, few other also work, some in lower case, some in upper case, some punctuations... When I write characters which doesn't work: with anti aliasing enabled, it will add some space (the width of the characters), and with anti aliasing disabled, it doesn't add any space, it's like I wrote nothing. Also, if I double click the font file, it opens in that Preview window and all characters are working normally as expected since the font works normally in Photoshop.. but I don't like Photoshop. Any idea how to solve the problem? Thanks in advance for any help Edit: well it was urgent job so I did it with Photoshop, but I'm still interested if you have a solution.
  14. No but problem solved, the whole thing was wrong because I used values between 0 and 255 when I should have used values between 0 and 1. Thanks anyway
  15. Of course, that was a bad example then... Ok another example. C1 alpha is 128, C2 alpha is also 128, the resulting alpha is 192. Another C1 alpha is 250, C2 alpha is 200, the resulting alpha is 254. How to calculate this? Edit: is this correct: floor( 255 - ( ((255 / C1.A) * C2.A) + ((1 - (C2.A / 255)) * C1.A) ) ) But now I realized the other calcualtions are wrong... Edit again: solved.
  16. Hello all, sorry I am new and need some help, it's not really related to Paint.NET usage, but how it calculate the resulting color: For example I make red background, call it C1: RGBA = 255, 0, 0, 255 Then I place a yellow pixel, call it C2: RGBA: 220, 216, 0, 200 Then I use the Color Picker tool on this pixel, I get C3: RGBA: 227, 169, 0, 255 I already know how to calculate R, G, and B of C3 R = ( (C2.A / 255) * C2.R ) + ( (1 - (C2.A / 255)) * C1.R ) = 227 G = ( (C2.A / 255) * C2.G ) + ( (1 - (C2.A / 255)) * C1.G ) = 169 B = ( (C2.A / 255) * C2.B ) + ( (1 - (C2.A / 255)) * C1.B ) = 0 But for the Alpha channel, it is different and I can't find how to calculate it! Thanks for any help
×
×
  • Create New...