logo
down
shadow

is it worth it to convert graphics from jpg to png?


is it worth it to convert graphics from jpg to png?

By : chetansi nanavati
Date : November 24 2020, 03:41 PM
I hope this helps . It is too late, you've already lost the fidelity. PNG cannot make lost pixels re-appear, that only works in the Law & Order crime lab. You also are quite liable to get a PNG that's larger than necessary due to the quantization noise, added when the JPEG data is converted back to a bitmap. You'll need your original artwork and skip the JPEG encoding step to go straight to PNG. It will never be a smaller file, just better.
code :


Share : facebook icon twitter icon
how to convert this function to use Stringbuilder, and is it worth it?

how to convert this function to use Stringbuilder, and is it worth it?


By : woz
Date : March 29 2020, 07:55 AM
will be helpful for those in need in the code example below would converting the function to use StringBuilder make it more efficient and be worth it? and , you can use
code :
StringBuilder.replace(int start, int end, String str)
How can convert FMX.Graphics.TBitmap to VCL.Graphics.TBitmap or Vcl.Imaging.PngImage.TPngImage?

How can convert FMX.Graphics.TBitmap to VCL.Graphics.TBitmap or Vcl.Imaging.PngImage.TPngImage?


By : Jose Raul Ajuria Bol
Date : March 29 2020, 07:55 AM
Hope this helps to David Heffernan and some search I wrote these functions as following.
I first come up with the function that doesn't support Alpha
code :
function ConvertFmxBitmapToVclBitmap(b:FMX.Graphics.TBitmap):Vcl.Graphics.TBitmap;
var
  data:FMX.Graphics.TBitmapData;
  i,j:Integer;
  AlphaColor:TAlphaColor;
begin
  Result:=VCL.Graphics.TBitmap.Create;
  Result.SetSize(b.Width,b.Height);
  if(b.Map(TMapAccess.Readwrite,data))then
  try
    for i := 0 to data.Height-1 do begin
      for j := 0 to data.Width-1 do begin
        AlphaColor:=data.GetPixel(i,j);
        Result.Canvas.Pixels[i,j]:=
          RGB(
            TAlphaColorRec(AlphaColor).R,
            TAlphaColorRec(AlphaColor).G,
            TAlphaColorRec(AlphaColor).B);
      end;
    end;
  finally
    b.Unmap(data);
  end;
end;
function ConvertFmxBitmapToPng(b:FMX.Graphics.TBitmap):Vcl.Imaging.PngImage.TPngImage;
var
  data:FMX.Graphics.TBitmapData;
  i,j:Integer;
  AlphaColor:TAlphaColor;
  AlphaLine:VCL.Imaging.PngImage.pByteArray;
begin
  result:=TPngImage.CreateBlank(COLOR_RGBALPHA, 8, b.Width, b.Height);;
  if(b.Map(TMapAccess.Readwrite,data))then
  try
    for i := 0 to data.Height-1 do begin
      AlphaLine:=Result.AlphaScanline[i];
      for j := 0 to data.Width-1 do begin
        AlphaColor:=data.GetPixel(j,i);
        AlphaLine^[j]:=TAlphaColorRec(AlphaColor).A;
        Result.Pixels[j,i]:=
          RGB(
            TAlphaColorRec(AlphaColor).R,
            TAlphaColorRec(AlphaColor).G,
            TAlphaColorRec(AlphaColor).B);
      end;
    end;
  finally
    b.Unmap(data);
  end;
end;
Is it worth it to convert array into set to search in NodeJS

Is it worth it to convert array into set to search in NodeJS


By : Naveen
Date : March 29 2020, 07:55 AM
will be helpful for those in need @jonrsharpe - particularly for your case, I found that converting an array of 2k to Set itself is taking ~1.15ms. No doubt searching Set is faster than an Array but in your case, this additional conversion can be little costly.
You can run below code in your browser console to check. new Set(arr) is taking almost ~1.2ms
code :
var  arr = [], set = new Set(), n = 2000;
for (let i = 0; i < n; i++) {
  arr.push(i);
};

console.time('Set'); 
set = new Set(arr);
console.timeEnd('Set');
var  arr = [], set = new Set(), n = 2000;
console.time('Array'); 
for (let i = 0; i < n; i++) {
  arr.push(i);  
};
console.timeEnd('Array');

console.time('Set'); 
for (let i = 0; i < n; i++) {
  set.add(i);  
};
console.timeEnd('Set');
var arr = [], set = new Set(), n = 100000;
for (let i = 0; i < n; i++) {
  arr.push(i);
  set.add(i);
}

var result;
console.time('Array'); 
result = arr.indexOf(12313) !== -1; 
console.timeEnd('Array');
console.time('Set'); 
result = set.has(12313); 
console.timeEnd('Set');
R from java with no graphics: is it worth moving to JRI

R from java with no graphics: is it worth moving to JRI


By : user3859294
Date : January 02 2021, 06:48 AM
hope this fix your issue My two cents:
I find working with JRI to be straight-forward. There are several examples provided with JRI that give a good demonstration of how to use it.
Is it worth it to convert all of my JComponents to AWT components?

Is it worth it to convert all of my JComponents to AWT components?


By : GreenApple
Date : March 29 2020, 07:55 AM
this will help AWT is actually a bit deprecated native-dependant GUI. It has lots of problems (including performance) and doesn't really act well on all of the various platforms.
The best way is to use either Swing, JavaFX or SWT to create rich desktop applications on Java. Each of the has lots of pros and cons - it would take a year to tell about all of them. The best way is to watch some of the samples and demos and decide what is best for you.
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org