It is currently Fri Oct 18, 2019 4:52 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 60 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Mon Aug 26, 2019 9:01 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3479
Location: Netherlands
You may be right that it has to do with the drawing of the alpha channel.
I would probably change the encode procedure to something like the code below and pass JPEGQuality -1 to encode for PNG.
Code:
; >> EncodeVorbisPicture procedure <<

UseJPEGImageEncoder()
UsePNGImageEncoder()

Procedure.s EncodeVorbisPicture(Image, PictureType = 3, JPEGQuality = 7)
 
  Protected *Image, MIMEType.s, Offset, ImageDataSize, BufferSize
 
  If JPEGQuality >= 0
    ; JPEG
    *Image = EncodeImage(Image, #PB_ImagePlugin_JPEG, JPEGQuality)
    MIMEType = "image/jpeg"
    Offset = 42
  Else
    ; PNG
    *Image = EncodeImage(Image, #PB_ImagePlugin_PNG, 0, 32)
    MIMEType = "image/png"
    Offset = 41
  EndIf
 
  ImageDataSize = MemorySize(*Image)
  BufferSize = ImageDataSize + Offset
 
  ; Allocate Buffer array and copy the encoded image to it
  Protected Dim Buffer.a(BufferSize - 1)
  CopyMemory(*Image, @Buffer(Offset), ImageDataSize)
  FreeMemory(*Image)
 
  ; Set the additional information
  Buffer(3) = PictureType
  Buffer(7) = PokeS(@Buffer(8), MIMEType, -1, #PB_Ascii | #PB_String_NoZero)
 
  Buffer(Offset-4) = ImageDataSize >> 24
  Buffer(Offset-3) = ImageDataSize >> 16
  Buffer(Offset-2) = ImageDataSize >> 8
  Buffer(Offset-1) = ImageDataSize
 
  ; Return Base64 encoded Buffer without CRLF
  ProcedureReturn ReplaceString(Base64Encoder(@Buffer(0), BufferSize), #CRLF$, "")
 
EndProcedure

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Mon Aug 26, 2019 10:46 am 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1024
Location: Portugal
Hi wilbert

I attacked it by having two procedures one for jpg and one for png with an extra field in the imagetag for mimetype.

Each png image is encoded with its original depth and then coupled with DrawAlphaImage() it works fine.

Changed it all as I am now starting to get ready to batch tag Artist and title from the filename and to rename files based on the tags.

Maybe could offer support for other image formats such as bmp?

CD

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Mon Aug 26, 2019 11:02 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3479
Location: Netherlands
collectordave wrote:
I attacked it by having two procedures one for jpg and one for png

That will also work fine :)

collectordave wrote:
Maybe could offer support for other image formats such as bmp?

Bmp isn't allowed. According to the file specification, an image has to be encoded as either jpeg or png.
So you can only load bmp files and recode as png or jpeg before embedding.
When it comes to png and jpeg images, you could also offer to embed the image as it is without recoding it.

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Tue Aug 27, 2019 5:23 am 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1024
Location: Portugal
Could load bmp then save as png etc will look into it a bit more.

Just added new li8nk to first page. Barch editing now possible for filename tags and writing filenames from tags.

More open format for the editor as well.

Regards

CD

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Tue Aug 27, 2019 5:59 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3479
Location: Netherlands
Unfortunately the current version doesn't work on macOS.
I think it has to do with the fact that macOS uses a forward slash for directories while Windows uses a backslash.

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Tue Aug 27, 2019 7:19 am 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4361
Location: Germany
Wondows also accept / as delimiter for directories :wink:


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Tue Aug 27, 2019 9:43 am 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1024
Location: Portugal
Trying on the mac and it works if everything is on the local drive except images.

Just tried openfilerequester on external drive and it fails on the mac posted a maybe bug.

CD

PS There is one bit in the select folder procedure where i use the \ changed to #PS$ and it loads.

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Tue Aug 27, 2019 10:11 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3479
Location: Netherlands
collectordave wrote:
Trying on the mac and it works if everything is on the local drive except images.

Just tried openfilerequester on external drive and it fails on the mac posted a maybe bug.

CD

PS There is one bit in the select folder procedure where i use the \ changed to #PS$ and it loads.


If I change the backslash, it does show the ogg files in a folder.
At first I assumed it would immediately show something if I would click on a filename but apparently I have to use the right-click button ?
If I do so, I can open a file and "Current song" shows the filename but the comment tags don't show anything.

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Tue Aug 27, 2019 10:25 am 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1024
Location: Portugal
Hi

After selecting a folder and the ogg files are shown in the list then right click gives the popup menu then select Load file and on my machine it shows the comments.


The popup is used to allow you to select multiple files to tag or rename.

CD

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Tue Aug 27, 2019 1:12 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3479
Location: Netherlands
collectordave wrote:
After selecting a folder and the ogg files are shown in the list then right click gives the popup menu then select Load file and on my machine it shows the comments.

It does show the tags now. Maybe I did something wrong.
There is however still a problem with showing embedded images.

ResizeImage doesn't return an image but resizes the original image.
Also when you draw an image, you need the ImageID which is not the same as the image number.
If you use DrawVectorImage, you don't need to resize the image and as far as I know, it will still work with transparent images.
Code:
      If StartVectorDrawing(CanvasVectorOutput(cnvArtWork))
        MovePathCursor(0, 0)
        DrawVectorImage(ImageID(EditTags()\ImageID), 255, adjustedwidth, adjustedheight)
        StopVectorDrawing()     
      EndIf

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Wed Aug 28, 2019 3:58 am 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1024
Location: Portugal
Link on first page updated with (working code) tested on mac and win7 64bit pb 5.71

CD

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Wed Aug 28, 2019 6:35 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3479
Location: Netherlands
collectordave wrote:
Link on first page updated with (working code) tested on mac and win7 64bit pb 5.71

It works better now :)

When I open an ogg file with a front cover image in it, select one of the image types (Back Cover or Artist) that doesn't have an image and select "Front Cover" again, I get a crash.

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Wed Aug 28, 2019 6:49 am 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1024
Location: Portugal
Works ok on windows will dig out mac and try

Cd

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Wed Aug 28, 2019 6:58 am 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1024
Location: Portugal
Missed one

Lines 837 etc in new win main need to be changed

Code:
 
                StartVectorDrawing(CanvasVectorOutput(cnvArtWork))
                    MovePathCursor(0,0)
                    DrawVectorImage(ImageID(EditTags()\ImageID),255,adjustedwidth,adjustedheight)
                  StopVectorDrawing()


Did the rest forgot this one.

Please try and tell me if this vures problem.

CD

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: ogg vorbis comment (tag)
PostPosted: Wed Aug 28, 2019 9:27 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3479
Location: Netherlands
collectordave wrote:
Lines 837 etc in new win main need to be changed

That fixes the problem. :)

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 60 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye