Jump to content

ioan

Members
  • Content Count

    18
  • Joined

  • Last visited

  • Days Won

    1

ioan last won the day on October 26

ioan had the most liked content!

Community Reputation

12 Good

Technical Information

  • Delphi-Version
    Delphi 10.4 Sydney

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I'm trying to use Vcl.Graphics.TWICImage on a Windows Server 2012 R2 and the following exception thrown: EInvalidGraphicOperation: Cannot create instance of class CLSID_WICImagingFactory (800401F0) Anyone knows the reason? On my development machine with Windows 10 Pro works fine. Oops, never mind, it seems that I forgot CoInitialize/CoUninitialize
  2. Well, I found the problem... I had to save to file the stream Data, not the original WicImage. Also, I had to keep the width/height as the original: uses avconst, activex, varutils, wincodec, consts; procedure ChangeTiffCompression(tiffFilename: string; tiffNewFileName: string); var Encoder: IWICBitmapEncoder; Frame: IWICBitmapFrameEncode; Props: IPropertyBag2; LStreamAdapter: IStream; PixelFormat: TGUID; LStream: IWICStream; Palette: IWICPalette; Data: TMemoryStream; ImagingFactory: IWICImagingFactory; WicImage: TWICImage; Options: TPropBag2; varValue: TPropVariant; hr: HRESULT; begin Data := TMemoryStream.Create; WicImage := TWICImage.Create; try WicImage.LoadFromFile(tiffFilename); Data.Clear; LStreamAdapter := TStreamAdapter.Create(Data); ImagingFactory := TWICImage.ImagingFactory; ImagingFactory.CreateStream(LStream); LStream.InitializeFromIStream(LStreamAdapter); ImagingFactory.CreateEncoder(WicImage.EncoderContainerFormat, guid_null, Encoder); Encoder.Initialize(LStream, WICBitmapEncoderNoCache); Encoder.CreateNewFrame(Frame, Props); FillChar(Options, SizeOf(Options), 0); Options.pstrName := POleStr('TiffCompressionMethod'); varValue.vt := VT_UI1; varValue.bVal := WICTiffCompressionCCITT3; hr := Props.Write(1, @Options, @varValue); if not SUCCEEDED(hr) then raise Exception.Create('Error Props.Write'); hr := Frame.Initialize(Props); if not SUCCEEDED(hr) then raise Exception.Create('Error Frame.Initialize'); WicImage.Handle.GetPixelFormat(PixelFormat); Frame.SetPixelFormat(PixelFormat); Frame.SetSize(WicImage.Width, WicImage.Height); ImagingFactory.CreatePalette(Palette); WicImage.Handle.CopyPalette(Palette); Frame.SetPalette(Palette); Frame.WriteSource(WicImage.Handle, nil); Frame.Commit; Encoder.Commit; Data.Position := 0; Data.SaveToFile(tiffNewFileName); finally Encoder := nil; ImagingFactory := nil; Data.Free; WicImage.Free; end; end;
  3. I advanced a little with this puzzle, but still the compression method is not changed in the new created tiff. I used this example from Windows documentation: https://docs.microsoft.com/en-us/windows/win32/wic/-wic-creating-encoder?redirectedfrom=MSDN#tiff-encoding-example Also, I used as a starting point the procedure TWICImage.SaveToStream(Stream: TStream); from unit Vcl.Graphics; The procedure bellow creates a new tiff, but the compression method is the same as the old tiff. Any idea how to do this right? uses avconst, activex, varutils, wincodec, consts; const FAX_WIDTH = 1728; FAX_HEIGHT = 2150; procedure ChangeTiffCompression(tiffFilename: string; tiffNewFileName: string); var Encoder: IWICBitmapEncoder; Frame: IWICBitmapFrameEncode; Props: IPropertyBag2; LStreamAdapter: IStream; PixelFormat: TGUID; LStream: IWICStream; Palette: IWICPalette; Data: TMemoryStream; ImagingFactory: IWICImagingFactory; WicBitmap: TWICImage; Options: TPropBag2; varValue: TPropVariant; begin Data := TMemoryStream.Create; WicBitmap := TWICImage.Create; try WicBitmap.LoadFromFile(tiffFilename); LStreamAdapter := TStreamAdapter.Create(Data); ImagingFactory := TWICImage.ImagingFactory; ImagingFactory.CreateStream(LStream); LStream.InitializeFromIStream(LStreamAdapter); ImagingFactory.CreateEncoder(GUID_ContainerFormatTiff, guid_null, Encoder); Encoder.Initialize(LStream, WICBitmapEncoderNoCache); Encoder.CreateNewFrame(Frame, Props); FillChar(Options, SizeOf(Options), 0); Options.pstrName := POleStr('TiffCompressionMethod'); varValue.vt := VT_UI1; varValue.bVal := WICTiffCompressionCCITT3; Props.Write(1, @Options, @varValue); Frame.Initialize(Props); WicBitmap.Handle.GetPixelFormat(PixelFormat); Frame.SetPixelFormat(PixelFormat); Frame.SetSize(FAX_WIDTH, FAX_HEIGHT); ImagingFactory.CreatePalette(Palette); WicBitmap.Handle.CopyPalette(Palette); Frame.SetPalette(Palette); Frame.WriteSource(WicBitmap.Handle, nil); Frame.Commit; Encoder.Commit; WicBitmap.SaveToFile(tiffNewFileName); Encoder := nil; ImagingFactory := nil; finally Data.Free; WicBitmap.Free; end; end;
  4. I'm want to change the compression for a tiff file and I can't find any way to do it. I searched all the code samples from Microsoft, everything I found in Delphi, but no luck. I don't have much to show, everything I tried failed. Here is my code, any idea how to do this? procedure ChangeTiffCompression(tiffFilename: string; tiffNewFileName: string); var Source : TWICImage; Factory: IWICImagingFactory; Encoder: IWICBitmapEncoder; begin Source:= TWICImage.Create; try Source.LoadFromFile(tiffFilename); Factory := TWICImage.ImagingFactory; Factory.CreateEncoder(CLSID_WICTiffEncoder, guid_null, Encoder); // black magic here.... // and set compression to WICTiffCompressionCCITT3 // ????? Source.Handle := IWICBitmap(Encoder); Source.SaveToFile(tiffNewFileName); Encoder := nil; Factory := nil; finally Source.Free; end; end;
  5. After installing 10.4.1 it seems that "Right click -> Find Declaration" in the source code doesn't find the declaration most of the time. It seems that if I open the source where the the function or object is declared, it finds it, but most of the time it fails. You can see in the screenshot that "Declared in..." it's empty when I hover over TFaxPrepareTh. Does any of you have this problem also?
  6. ioan

    10.4.1 Released today

    Do I need to recompile 3rd party component libraries that worked in 10.4 or the same version will work in 10.4.1?
  7. It seems that the problem is from the welcome page. If the welcome page is closed, so far, everything seems that is working fine. If the welcome page is open, it seems that after a while the IDE starts acting up. At least that's my observation so far.
  8. Today, I have no idea why, every time I try to open pas file from the current project the IDE closes itself. Same if I try to open another project. This only started happening constantly today, to the point that I practically can't use it. Yesterday and the days before, I saw it happen few times, but I thought "oh well, it's almost normal to have the Delphi IDE crash from time to time". Today it got so bad and rebooting the system doesn't fix the problem. Have any of you see the same problem? Any fix? I will try to uninstall Patch 3, but it was installed when it came out, and this problem started only few days ago and now it got to the point of being unable to use it.
  9. ioan

    TeeChart & Delphi 10.4?

    I can't find TeeChart anywhere in Delphi 10.4, is it not available for free anymore? Never mind, I found it!
×