Author Topic: Tags Library  (Read 63198 times)

EWeiss

  • Posts: 354
Re: Tags Library
« Reply #425 on: 8 Dec '17 - 12:19 »
Quote
EWeiss: When passing a variable by reference, the pointer to the variable is sent. When passing a variable by value, the variable's value is copied to the stack (depends on the calling convention, might be a register too) for the function that expects it. If you pass a reference (pointer) to a struct only the pointer is copied to the stack, if you send the struct by value, the whole structure is copied to the stack.

What are you trying to tell me?
I worked with VB6 for 15 years before I went to Delphi..

read all my hints and do not tell me what and why something is not working.
I told you that it does not work with ByVal only over ByRef
so do not tell me anything.

That's clear to me.

for you too? i hope now

greets
« Last Edit: 9 Dec '17 - 06:50 by EWeiss »

Steve Grant

  • Posts: 145
Re: Tags Library
« Reply #426 on: 8 Dec '17 - 22:15 »
I have tried the latest. It works!!!!

Test Code:

Code: [Select]
Dim CoverArt As TCoverArtData, lTags As Long, FileName As String
    ChDrive App.Path '//This just forces the program to look in the current folder
    ChDir App.Path '//This just forces the program to look in the current folder
    FileName = App.Path & "\Bonanza.flac"
    If lTags = 0 Then lTags = TagsLibrary_Create
    TagsLibrary_Load lTags, StrPtr(FileName), ttAutomatic, True
    ImageStart.Picture = LoadPicture(App.Path & "\Pic.jpg")
    CoverArt.Name = StrPtr("Cover Art 1")
    CoverArt.CoverType = 3 '//* ID3v2 cover type (3: front cover)
    CoverArt.MIMEType = StrPtr("image/jpeg")
    CoverArt.Description = StrPtr("Front")
    CoverArt.width = ScaleX(ImageStart.width, vbTwips, vbPixels)
    CoverArt.height = ScaleY(ImageStart.height, vbTwips, vbPixels)
    CoverArt.ColorDepth = 24
    CoverArt.NoOfColors = 0
    CoverArt.PictureFormat = tpfJPEG
    CoverArt.Data = 0 '; //PictureStream.Memory;
    CoverArt.DataSize.LowPart = 0 '//PictureStream.Size;
    CoverArt.DataSize.HighPart = 0 '//PictureStream.Size;
    TagsLibrary_AddCoverArtFromFile lTags, ttAutomatic, StrPtr(App.Path & "\Pic.jpg"), CoverArt
    TagsLibrary_Save lTags, StrPtr(FileName), ttAutomatic
    TagsLibrary_Free lTags

This is the Declare:

Code: [Select]
Public Declare Function TagsLibrary_AddCoverArtFromFile Lib "TagsLib.dll" (ByVal Tags As Long, ByVal TagType As TTagType, ByVal FileName As Long, ByRef CoverArt As TCoverArtData) As Long
As I won't know the parameters of the downloaded image, is it safe to always use 24 for the BitDepth?

Many many thanks.


EWeiss

  • Posts: 354
Re: Tags Library
« Reply #427 on: 9 Dec '17 - 06:52 »
Quote
is it safe to always use 24 for the BitDepth?
read the Bitmap Header and use the BitDeph from Image Handle which your use.
see! bmBitsPixel

Code: [Select]
Public Function GetBitmapInfo(ByVal hBitmap As Long, _
                              Optional ByRef Return_Height As Long, _
                              Optional ByRef Return_Width As Long, _
                              Optional ByRef Return_BitsPerPixel As Integer, _
                              Optional ByRef Return_Size As Double, _
                              Optional ByRef Return_PointerToBits As Long) As Boolean
On Error Resume Next
 
  Dim BMP As BITMAP
 
  ' Clear the return variables
  Return_Height = 0
  Return_Width = 0
  Return_BitsPerPixel = 0
  Return_Size = 0
  Return_PointerToBits = 0
 
  ' Check that there's a valid input
  If hBitmap = 0 Then Exit Function
 
  ' Get the information
  If GetObjectAPI(hBitmap, Len(BMP), BMP) = 0 Then Exit Function
 
  ' Return the information
  With BMP
    Return_Height = .bmHeight
    Return_Width = .bmWidth
    Return_BitsPerPixel = (.bmBitsPixel * .bmPlanes)
    Return_Size = ((.bmWidth * 3 + 3) And &HFFFFFFFC) * .bmHeight
    Return_PointerToBits = .bmBits
  End With
 
  ' Function succeeded
  GetBitmapInfo = True
 
End Function

greets
« Last Edit: 9 Dec '17 - 07:01 by EWeiss »

Steve Grant

  • Posts: 145
Re: Tags Library
« Reply #428 on: 9 Dec '17 - 09:23 »
@Emil many thanks.

Is Return_Size always aligned?

Greets

EWeiss

  • Posts: 354
Re: Tags Library
« Reply #429 on: 9 Dec '17 - 10:24 »
@Emil many thanks.

Is Return_Size always aligned?

Greets

what your mean?
the size is from Original File.. is not the size from Picturebox if your load it and resize (align) it to PictureBox.

Code: [Select]
    Return_Height = .bmHeight
    Return_Width = .bmWidth

is the correct size of the original Image to.
test it should not be a Problem i think ;)

greets

Steve Grant

  • Posts: 145
Re: Tags Library
« Reply #430 on: 9 Dec '17 - 21:36 »
@Emil, sorry I should have been clearer. When reading up on this to try and learn, I read that the returned Data Size has to be DWord aligned.  (divisible by 4)

3delite

  • Posts: 903
Re: Tags Library
« Reply #431 on: 10 Dec '17 - 09:59 »
Good to hear that it works now! :)

The package has been updated, download link in the first post:

  • New function TagsLibrary_AddCoverArtFromFile() for the .dll version
  • Fixed (ID3v2) 'PlayTime' for exotic MPEG formats
  • Delphi ID3v2 unit: changed all {$IFDEF CPUX64} to {$IFDEF WIN64}
  • Updates for Lazarus/Free Pascal for the ID3v1 unit