delphi,graphics,png,gif , How can I convert PNG to GIF keeping the transparency?


How can I convert PNG to GIF keeping the transparency?

Question:

Tag: delphi,graphics,png,gif

How can I convert PNG to GIF keeping the transparency?

I would have hoped that using the Assign( ) method would work but it doesn't seem to migrate transparency. In the GIF, it's represented as black.

    png:=TPngImage.Create;
    try
      png.LoadFromFile(sFile);
      // comes from file:  png.TransparencyMode;
      // comes from file:  png.Transparent

      // didn't help:  gif.Transparent:=true;

      gif.Assign(png);

      // didn't help:  gif.Transparent:=true;

      gif.SaveToFile('e:\tmp\out.gif');
    finally
      png.Free;
    end;

I haven't found a way to handle this in Delphi...

thanks!


Answer:

It is possible to transfer an image from a PNG to a GIF. However, I don't recommend that you do so. The GIF format is substantially less capable than PNG. PNG supports RGBA color channels and partial transparency. GIF uses a 256 color palette and no support for partial transparency.

There are many libraries available that will make the best of a bad job and attempt to produce a GIF image that is close to the PNG image, but information will be lost.

The GIF format dates from the late 1980s and time has moved on. It has long since served its purpose. PNG is modern, capable and well supported. If it is possible to do so you should switch from GIF to using PNG.


Related:


AttributeError: '_Screen' object has no attribute 'mainloop'


python,python-2.7,graphics,turtle-graphics
I'm designing a simple Python program that uses the Turtle graphics module to draw lines on the screen with the arrow keys. import turtle turtle.setup(400,500) # Determine the window size wn = turtle.Screen() # Get a reference to the window wn.title("Handling keypresses!") # Change the window title wn.bgcolor("lightgreen") # Set...

Set node state in a virtual tree


delphi,nodes,virtualtreeview
I have created a virtual tree with multiple node and I want to disable some of them. I've seen there's a States property of a node. Which is a property of a type TVirtualNodeStates so I've check what kind of states I can set and apparently TVirtualNodeStates is a set...

Delphi Bug in Indy FTP List method?


delphi,ftp,indy
I'm trying to generate a list of files matching a certain file mask and Indy falls over with this error EidReplyRFCError with message '.': No such file or directory. I've tried several variations and this is the result: FTP.List( aFiles, '', true ); => this works FTP.List( aFiles, '*.*', false...

Buttons and paint method


java,swing,graphics,jbutton,actionlistener
I'm having trouble with my buttons. I know they're working because I've tested them out by exiting the problem through System.exit. Here is what my output looks like: http://imgur.com/Ks7mIFa When I click the close button, the handle on the switch should redraw to the other side and the close button...

Reduce lines, use case?


delphi,case
How to reduce the lines, I could use case? I feel that this code is too large, no way to improve? if valmes.Text = '01' then WebTesta.OleObject.Document.all.Item('expmonth', 0).value := '0'; if valmes.Text = '02' then WebTesta.OleObject.Document.all.Item('expmonth', 0).value := '1'; if valmes.Text = '03' then WebTesta.OleObject.Document.all.Item('expmonth', 0).value := '2'; if valmes.Text...

Why am I getting a QWidget error?


python,graphics,drawing,pyqt4
I have recently found this person's code that I could possibly be able to use for my project but I'm still pretty new to Python so I'm having a really rough time understanding the code and the error that keeps occurring even though the code is exactly the same as...

Why is Java Graphics not painting?


java,graphics
I'm a bit new to programming right now and am trying to make Pong in java. However I'm not able to make any graphics show up. Main Class public class Pong1 { public static Frame frame = new Frame(); public static Panel panel = new Panel(); public static void main(String[]...

How to upscale and render remote(RGB565) frame buffer on Android native?


android,graphics,android-ndk,android-gui,surfaceflinger
I have ported remote frame buffer receive C code on Android 4.2.2 which receives frame buffer from host in RGB565 format. Able to render the received framebuffer following the standard android example frameworks/native/services/surfaceflinger/tests/resize/resize.cpp. Following is the code snippet used sp<Surface> surface = client->createSurface(String8("resize"), 800, 480, PIXEL_FORMAT_RGB_565, 0); SurfaceComposerClient::openGlobalTransaction(); surface->setLayer(100000); SurfaceComposerClient::closeGlobalTransaction();...

Asynchronous TADOQuery's OnFetchComplete not synchonized to main thread


delphi,asynchronous,delphi-xe4,delphi-xe8,tadoquery
When using TADOQuery with [eoAsyncFetchNonBlocking] and attaching to OnFetchComplete event I found that OnFetchComplete is not executing in the main thread (tested in XE4 and XE8). I assume this a bug*, since most of us will do work in the UI on these type of event. I believe this to...

Custom component controls keep re-creating


delphi,firemonkey
I'm a newbie in Firemonkey/custom controls so sorry if this is a banal question or a duplicate one but I'm stuck and can't figure it out. Here's the code of my custom control unit swScheduler; interface uses System.SysUtils, System.Classes, FMX.Types, FMX.Controls, FMX.StdCtrls, FMX.Calendar, FMX.Objects; type TswScheduler = class(TControl) private {...

Can the OpenGL 'deprecated' functions possibly be unsupported?


c++,c,opengl,graphics,deprecated
I am testing with glDrawPixels to port my simple pixel-drawn 2D game from Windows API to OpenGL with GLFW. It runs nicely with FPS over 100, additionally cross-platform. Just one thing that is slightly annoying me is that I'm using a deprecated feature. I don't see any problems now, but...

HasValidFileNameChars fails for UNC files


delphi,delphi-xe,delphi-xe7
For me HasValidFileNameChars function (in Delphi XE7) returns false for UNC files: B:= IOUtils.TPath.HasValidFileNameChars('\\ETA-PC\tests\test.ini', FALSE) B is false now This means that if you try to validate the filename that I show in my test (yes the file is real and as you can see its name is correct) HasValidFileNameChars...

Java Unicode character displaying box instead of Runic letter


java,string,unicode,graphics
I am trying to draw random Nordic runes in a little Java game, but all I'm getting back is a square character. public class MyComponent extends JComponent { public void paintComponent(Graphics g) { String s = "\u16A8"; g.drawString(s,50,50); } } What the character should be displaying: https://en.wikipedia.org/wiki/Ansuz_(rune) What it's actually...

See when Delphi Twebbrowser starts loading a page


delphi,twebbrowser
I am using delphi's TWebbrowser to navigate to a php file I created. I have a loading screen I would like to show when the page is loading or processing commands. How can I detect when it is being refreshed or still loading. currently I am using the ondocumentcomplete to...

Referring to interface versus to an object implemeting it?


delphi
Given the following declarations: var XML:IXMLDocument; and var XML:TXMLDocument; What's the difference of working with the XML variable from end-user point of view? What's preferred?...

How to remove duplicates in ListBox?


delphi,listbox,duplicate-removal
I use this code to remove duplicates: procedure TForm1.RemoveDuplicates(StrList : TStringList); var NoDuplicate: TStringList; i: Integer; begin NoDuplicate := TStringList.Create; try NoDuplicate.Sorted := True; NoDuplicate.Duplicates := dupIgnore; /// for i := 0 to StrList.Count - 1 do NoDuplicate.Add(StrList[i]) ; /// NoDuplicate.Sorted:= False; StrList.Assign(NoDuplicate) ; finally NoDuplicate.Free; end; end; It works...

do oncalculate fields in one table using values from another table


delphi
I am doing calculations in my KLOG table. However, my PRICES table has the data I need for the calculations in the KLOG table. Example : KLOG table has PRICE_ID field (integer). So does the PRICES table. So I am trying to do something like this (oncalculatefields of the KLOG...

Is there any Delphi implementation of MurMurHash3?


delphi,murmurhash
Is there any Delphi implementation of MurMurHash 3? I tried implementing it myself, but my implementation is actually slower that the MurMurHash2. Is it normal? Is there any other implementation? This is mine: function MurMur3_32(const S: AnsiString; const Seed: LongWord=$9747b28c): LongWord; const c1 = $cc9e2d51; c2 = $1b873593; r1 =...

Firemonkey ListView item indexes not updating


delphi,listview,firemonkey
I'm using a TListView in Firemonkey. On startup, I create 3 list view headers and keep references to them for future use (specifically inserting items below each header). FItemHeader:= LV.Items.Add; FItemHeader.Purpose:= TListItemPurpose.Header; FItemHeader.Text:= 'Items'; FChargeHeader:= LV.Items.Add; FChargeHeader.Purpose:= TListItemPurpose.Header; FChargeHeader.Text:= 'Charges'; FPaymentHeader:= LV.Items.Add; FPaymentHeader.Purpose:= TListItemPurpose.Header; FPaymentHeader.Text:= 'Payments'; Then, I've added a...

How to use TThread.Synchronize() to retrieve the text of a TEdit control?


delphi,c++builder
How can I use TThread.Synchronize() to retrieve the text of a TEdit control. Should I assign the TEdit text to a global variable or something?

Delphi XE8: problems running an external console application, waiting for its results and capturing its results


delphi,pipe,console-application,createprocess,waitforsingleobject
In Delphi XE8 under Windows, I am trying to call an external console application and capture its output. I use the following code, as described in Capture the output from a DOS (command/console) Window and also Getting output from a shell/dos app into a Delphi app: procedure TForm1.Button1Click(Sender: TObject) ;...

Missing operator or semicolon in Delphi 7


delphi,delphi-7
I've got the error message "Missing operator or semicolon" on line 38 of this code: procedure TForm1.SpinEdit1Change(Sender: TObject); begin case SpinEdit1.Value of 1: Label6.Caption('rok'); // line 38 end; end; end. Does somebody know what I am missing? Thank you....

How to make TDBCheckBox update its DataField immediately after click?


delphi,checkbox,event-handling,delphi-xe3,data-aware
I have a form with several controls where the first one is a TDBCheckBox that is bound to DataField := 'enabled'. When the checkbox is clicked I want all the remaining controls to be enabled / disabled. procedure TMyAdapter.DataSourceDataChange(Sender: TObject; Field: TField); var Enabled: Boolean; begin Enabled := FModel.DataSet['enabled'].AsBoolean; FView.Label1.Enabled...

Delphi generic frame


delphi,frames
I'm still here with a questione about Delphi frames. I would like to create an application that use various type of frames in order to manage different database tables, so trying to understand how to do this kind of task I've create a simple Delphi Form: unit main; interface uses...

Delphi - extract string between tags (duplicate tags)


delphi
I'm trying to write a function to extract a string between two tags. The problem is that the first tag is a duplicate in that string with an unknown count e.g. Str := 'Delphi App Hello Hello SomeText here Hello Hello Hello This is a Test!'; What i want exactly...

How to make a Javafx Image Crop App


java,image,canvas,graphics,javafx
I am building an application for my colleagues to crop image. I use FXML with Scene Builder to build the GUI. The user click a button to choose a image from his computer. Then, the image is shown in the GUI. User can zoom and move in the pane. At...

Delphi - Use a string variable's name in assignfile()


file,delphi,variables,assign
Is it possible to use a variable in the assignfile command? Eg. f : Textfile ; sFile : string ; {contains 'MyFile.txt' as content} ... cFileDir = 'C:\Users\User\Desktop\Data Engine\Data\Country' ; ... Assignfile(f, cFileDir + '\' + sFile) ; ... I appreciate your help very much. if it's unclear I'll edit...

How to create an indent in shaped control that allows painting on indented region?


c#,graphics,shape
I have a custom control, which I am applying a shape to. The shape has a pointer (similar to the message indicator in Skype that shows if the message was a received message, or a sent message) that is on the left or right side. When the indicator is on...

picture box crossed out C#


c#,graphics,2d,picturebox,gdi
I have a project in which I draw several rectangles using GDI. I do it using i++ from i=0 to i<=10. I use e.Graphics.FillRectangles. I refresh the drawn rectangles every 1/10s by calling Graphics.Invalidate() My problem is that my picture box gets crossed out when drawing more the 4 rectangles....

Currency Formatting with Delphi


delphi,currency,object-pascal
I am trying to writte a code in Delphi, which will be displaying a given number in currency format like this: Now it works if filled whole number and another field until any paramater is updated. I'd be happy to have a code which would displaying a number in currency...

SetProcessWorkingSetSize does not work in compiling 64bit


delphi,memory
I use the following command to reduce the memory usage of my program, I'm actually testing it, only when I compile the program in 64bit this command does not work fot, no error occurs, only the memory in task managerIt does not decrease too, since in compiling 32bit works perfectly,...

Animation not adding to JFrame


java,swing,graphics
I'm new to java swing, so forgive me if my mistake is extremely obvious. What my code is supposed to do here is create one JFrame and animate two boxes moving upwards through the frame side by side. However, I'm seeing only one box (the blue box created by the...

Spotlight with shadows becomes square-like


c++,opengl,graphics,shader,shadow
I've been following a two part tutorial on shadow mapping from OGLDev (part 1, part 2) for a couple of days now, and I've nearly finished implementing it. My problem is that when I enable shadow maps the illuminated region which shadows appear in appears as a "strip" and I'm...

Errors trying to add rectangles to JPanel


java,swing,debugging,graphics
I am trying to draw a grid of rectangles on a JPanel that already has a few JButtons on it. I get a big list of errors when I try to run it. Here's my code: package GameOfLife; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.*;...

PasswordChar in Delphi XE8's TMemo


delphi,delphi-xe8
I spent a few hours searching Google to see if anyone had shared their articles, but came up empty-handed. If it's possible, I want to know how to enable/disable the passwordChar in Delphi XE8's TMemo to hide user input like in TEdit. ? Maybe via a checkbox! So when the...

It is required to free the IShellFolder interface returned by SHGetDesktopFolder ? and how?


delphi,delphi-2009
I am confused. I want to use the function PathToPidlBind from Jedi JCL and I see that they don't release the IShellFolder interfece reurned by SHGetDesktopFolder after using it. Microsoft docs says: "The calling application is responsible for eventually freeing the interface by calling its IUnknown::Release method.". I tried to...

How can I extract part of a PChar into a string?


string,delphi,optimization,pchar
During profiling I came across a function that was taking quite a bit of time, but essentially boiled down to this very simple piece of code: function GetSubstring(AInput: PChar; AStart, ASubstringLength: Integer): string; begin Result := Copy(AInput, AStart, ASubstringLength); end; This function returns the expected sub-string, but it doesn't scale...

How to get enabled property of a control?


delphi,properties
In Delphi it is possible to get the process name and class name of any control which is clicked system wide via windows api. process name: GetWindowThreadProcessId(Hwnd, ProcessId) by process ID one can get to the process name class name: SetLength(ClassName, 255); SetLength(ClassName, GetClassName(Hwnd, pchar(ClassName), 255)); Is there an easy...

Does “enable runtime themes” affect performance?


delphi,themes,delphi-2007
I've recently changed "enable runtime themes" value in the project options and I'm wondering if it's value affects application's performances and, in case, in which manner? Hope someone can clarify me this point.

Function that returns intersection of two TShapes, including TPaths?


delphi,firemonkey
Anyone have any knowledge of a function that returns the intersection TPath for two TShapes? Especially one that returns the intersection TPath of two TPaths. For instance: pthIntersection := PathIntersection(Path1,Path2); ...

how to refresh JFrame after after adding java 2d components


java,swing,graphics,graphics2d
in this code i added two components to the jframe and also used revalidate and repaint but only one of the components is being viewed. i need a way to refresh the jframe class A extends JPanel{ int i ,j; A(int i,int j){ this.i = i; this.j = j; }...

How to make my custom control be notified when his form or application receives and loses focus?


delphi,focus,delphi-2009
I want my control to receive distinct notifications only when it's parent form (not panel or something else, just the main form of this control) receives and loses focus. Doesn't matter if the focus is switched from another form of the application or between my application and other application, it...

Issues with AES Encryption using SynCrypto


delphi,encryption,cryptography,aes
Am trying to encrypt a file using SynCrypto.pas with AES 256, but it fails if I try to encrypt a file whose size is not a multiple of 16 bytes. The decrypted data contains junk. Example: Original string in txt file we are testing the file Encrypted String [ù[„|wáî}f *!4ìÙw¬•ü¨s...

connection refused when I try to connect client with server


delphi,datasnap
I made a basic client / server datasnap applications and it work in local network through http but when I tried to connect from the internet I get connection refused, here are the steps I followed: I set at the server component TDSHTTPService to connect through port no 8081 then...

how to connect to a NIC card or network adapter knowing its IP address?


delphi,network-programming,ip-address,windows-10
Say I have two NIC or adapter card on my system and also I found their IP address through the following code: procedure TForm4.RetrieveLocalAdapterInformation(strings: Tmemo); var pAdapterInfo, pTempAdapterInfo: PIP_ADAPTER_INFO; AdapterInfo: IP_ADAPTER_INFO; BufLen: DWORD; Status: DWORD; strMAC: String; i: Integer; begin strings.Clear; BufLen:= sizeof(AdapterInfo); pAdapterInfo:= @AdapterInfo; Status:= GetAdaptersInfo(nil, BufLen); pAdapterInfo:= AllocMem(BufLen);...

Why Application.OnException never runs?


delphi,exception-handling,delphi-xe2,delphi-7
Problem summary: The method assigned to Application.OnException never runs when an unhandled exception occurs. I create a blank project with only this unit and place a single button on Unit.dfm (this is based on an official example) : // Unit1.pas // ********* type TForm1 = class(TForm) Button1: TButton; procedure FormCreate(Sender:...

How to call the original class's code when a class helper is in scope?


delphi,class-helpers
I'm doing some unit testing on an improved version of quicksort. The (hopefully) faster version is implemented using: TArrayHelper = class helper for System.Generics.Collections.TArray .... class procedure Sort<T>(var Values: array of T); overload; static; class procedure Sort<T>(var Values: array of T; Comparer: IComparer<T>); overload; static; .... I know for now...

Open file manage and get selected file


android,delphi,firemonkey
Using Delphi XE 8 and building Android app, can I browse files in the device by opening a certain file manager app installed on the device and then get back that selected file name and path ?

How to implement .png pics in a JFrame?


java,graphics,jframe,awt
What I want to do is making a window, a GUI, and putting an image in it. I watched a YT tutorial (https://www.youtube.com/watch?v=Ap20Qw77TzY) and copied everything similar but the Window I make has no image at all. I tried different file types like .jpg and different window sizes, matching he...

Component event detection in Delphi


delphi,events,components
I am developing a DataAware component and executing some code after the database is open. This is the code I have at the moment: TMyDataAwareComponent = class(TDataAwareComponent) private { Private declarations } procedure ToBeExecutedOnAfterOpen(DataSet: TDataSet); protected { Protected declarations } public { Public declarations } constructor Create(AOwner: TComponent); override; end;...