Jump to content

.bmrl filetype development


Recommended Posts

Let's discuss here issues regarding the development of an .bmrl filetype plugin.

 

There are .bmp files out there which do not contain Windows bitmap files. The signature is "RL" instead of "BM". Standard Windows viewers are not able to open these kind of .bmp files.

The content of the the files is a run-length endcoded 8-bit indexed format which allows multiple palettes and an alpha channel.

These files are used for iGO POI icons.

 

We are not able to enhance or replace the built-in .bmp loader/saver so we have to choose a different filename extension and the user has to change the extension if she likes to edit the file in paint.net. My favorite extension is - in the moment - .bmrl . Because you just have to change the p to rl ,-)

 

There seems to be no official specification describing the format. But we got a kind of reference implementation in c (open source).

 

To implement load in c# is easy enough. Save is more tricky because standard color quantization does not respect an alpha channel . There are ideas how this can be done (if the reference implementation is not sufficient).

 

Comments are welcome.

 

  • Like 1

midoras signature.gif

Link to comment
Share on other sites

OK, here is a quick shot for a .bmrl filetype supporting open.

It requires paint.net 4.3.0 alpha and uses no obsolete methods 😉

As Rick mentioned the portable version of 4.3.0 can be used in parallel to the latest 4.2.16.

You just can not run both at the same time.

 

(Removed the old version of the plugin)

 

And the example file provided by @lingfude.

 

BMRL_example.zip

  • Like 1

midoras signature.gif

Link to comment
Share on other sites

6 hours ago, Rick Brewster said:

4.3 can't be installed in parallel, but you can use the portable version to achieve what you're thinking of.

OK, I replaced installed with used in the sentence above. Just if someone is confused about how a portable version can be installed.

  • Like 1

midoras signature.gif

Link to comment
Share on other sites

16 hours ago, midora said:

OK, here is a quick shot for a .bmrl filetype supporting open.

It requires paint.net 4.3.0 alpha and uses no obsolete methods 😉

As Rick mentioned the portable version of 4.3.0 can be used in parallel to the latest 4.2.16.

You just can not run both at the same time.

 

Great and thanks!

Tested on paint.net 4.3 and works great to open this bmp file type (renamed to .bmrl).

I will wait to test the saving part. ;)

More examples attached.

bmp_800_480.zip

Edited by lingfude
Link to comment
Share on other sites

This version of the plugin allows to save as .bmrl.

There is a restriction in the amount of colors which can be handled (Not more than 251 different RGBAs in a row).

The reason is that in this case a quantizer has to be called. But this a little bit special if you are working in a 16-bit 565 color space with 5-bit alpha.

The source calls WuQuantizer16() to do the job. But this source is not included. If the source is available I would use this one.

We may also quantize the BGRA image to 256 colors first. But not now. Typically icons are small enough that there is no issue with the code.

Some png test images should be created to stress the save method.

 

 

 

 

 

 

  • Like 1

midoras signature.gif

Link to comment
Share on other sites

I try it but got this error when try to save:

Spoiler

Exception:

System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\TempTemp\Temp.bmrl'.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.OpenWrite(String path)
   at PropertyBasedFileTypes.BmrlFileType.OnSaveT(Document doc, Stream output, PropertyBasedSaveConfigToken token, Surface scratchSurface, ProgressEventHandler progressCallback)
   at PaintDotNet.FileType`2.OnSave(Document input, Stream output, SaveConfigToken token, Surface scratchSurface, ProgressEventHandler callback) in D:\src\pdn\src\Data\FileType`2.cs:line 39
   at PaintDotNet.FileType.Save(Document input, Stream output, SaveConfigToken token, Surface scratchSurface, ProgressEventHandler callback, Boolean rememberToken) in D:\src\pdn\src\Data\FileType.cs:line 263
   at PaintDotNet.Dialogs.SaveConfigDialog.<>c__DisplayClass49_0.<UpdatePreviewAsync>b__0() in D:\src\pdn\src\PaintDotNet\Dialogs\SaveConfigDialog.cs:line 605
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at PaintDotNet.Dialogs.SaveConfigDialog.UpdatePreviewAsync(Document document, FileType fileType, SaveConfigToken saveConfigToken, CancellationToken cancelToken) in D:\src\pdn\src\PaintDotNet\Dialogs\SaveConfigDialog.cs:line 632

Diagnostics:

Application                                                  paint.net v4.3 (α 4.300.7921.1736)
Build Date                                                   8 de setembro de 2021
Expiration Date                                              1 de dezembro de 2021
Install type                                                 Classic

Aceleração por hardware (GPU) de renderização                True
Animações                                                    True
DPI                                                          96 (1,00x scale)
Idioma                                                       pt-PT

OS                                                           Windows 10 Home x64 (10.0.19043.0)
Runtime                                                      .NET 5.0.9 x64
Physical Memory                                              7 962 MB

CPU                                                          Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
    Speed                                                    ~2295 MHz
    Cores / Threads                                          2 / 4
    Features                                                 SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2

Video Card                                                   Intel(R) HD Graphics Family
    Dedicated Video RAM                                      112 MB
    Dedicated System RAM                                     0 MB
    Shared System RAM                                        2 048 MB
    Vendor ID                                                0x8086
    Device ID                                                0x0A16
    Subsystem ID                                             0x2166103C
    Revision                                                 9
    LUID                                                     0x0000E051
    Flags                                                    SupportMonitoredFences, KeyedMutexConformance
    Graphics Preemption                                      PrimitiveBoundary
    Compute Preemption                                       ThreadGroupBoundary
    Outputs                                                  1
    Feature Level                                            Direct3D_11_1
    DXGI Formats                                             A8_UNorm, B8G8R8A8_UNorm, R16G16B16A16_UNorm, R16G16B16A16_Float, R32G32B32A32_Float
    Buffer Precision                                         UNorm8bpc, UNorm8bpcSrgb, UNorm16bpc, Float16bpc, Float32bpc

Video Card                                                   NVIDIA GeForce GT 740M
    Dedicated Video RAM                                      2 009 MB
    Dedicated System RAM                                     0 MB
    Shared System RAM                                        3 981 MB
    Vendor ID                                                0x10DE
    Device ID                                                0x1292
    Subsystem ID                                             0x2166103C
    Revision                                                 161
    LUID                                                     0x0000E673
    Flags                                                    AcgCompatible, SupportMonitoredFences, KeyedMutexConformance
    Graphics Preemption                                      DmaBufferBoundary
    Compute Preemption                                       DmaBufferBoundary
    Outputs                                                  0
    Feature Level                                            Direct3D_11_0
    DXGI Formats                                             A8_UNorm, B8G8R8A8_UNorm, R16G16B16A16_UNorm, R16G16B16A16_Float, R32G32B32A32_Float
    Buffer Precision                                         UNorm8bpc, UNorm8bpcSrgb, UNorm16bpc, Float16bpc, Float32bpc

...

 

Link to comment
Share on other sites

36 minutes ago, midora said:

@lingfudeCould you also describe how the upload process to the device works and what tool you are using? Maybe it's not needed to rename the .bmrl file back to .bmp for upload. This would make things easier for you (and others).

 

 

I tested the .bmrl saved as .bmp on my GPS and it worked perfect. The upload is made with a USB Drive and the name of .bmp is set on a .xml file. As you suggest may be work if I set the name of the file as [name].bmrl in the XML file.
I will test with .bmrl extension instead of .bmp to see the result and then I give you feedback.

  • Upvote 1
Link to comment
Share on other sites

I created shell extensions to show thumbnails of .bmrl files and .bmp files (containing bmrl) in the Windows FileExplorer.

 

(removed .zip)

 

First time I did it in c# (based on a project on github, see readme). Astonishing that this works 😉

 

Maybe it would make sense to add a RL Marker to the .bmp thumbnails so that users already know that they can't be opened easily in a image processing tool.

 

 

  • Like 1

midoras signature.gif

Link to comment
Share on other sites

 Sorry the ReadMe file in the shellextensions zip was empty. Which makes it a bit difficult to install the dlls 😞

 

So here is a new zip WITH installation guide.

 

bmp+bmrl.thumbnail.shellextension.zip

 

Before installation (.bmrl already assigned to open with paint.net)

 

1900869739_XDropShadowThumbnails-2AlwaysOpenWithPaint_net.thumb.png.3f0c2d92b0e423bb7c3166f3ba4a1667.png

 

After installation

 

900747822_XDropShadowThumbnails-3AfterRegistration.thumb.png.52bc7eb6af00bf401e8d04d279c52424.png

.bmps containing athe BMRL format are showing RL in the top left corners. And .bmrl files the image plus the associated application.

 

  • Like 1

midoras signature.gif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...