Implement CreateProfileImage
To Combine Precense Icon, Profile Image, and Cosmetic To Make Final Profile Image
This commit is contained in:
parent
00df7505a7
commit
446745d4df
20
qtc-net-client-2/Forms/Profile.Designer.cs
generated
20
qtc-net-client-2/Forms/Profile.Designer.cs
generated
@ -37,13 +37,11 @@
|
|||||||
btnDecline = new Button();
|
btnDecline = new Button();
|
||||||
btnCancelRequest = new Button();
|
btnCancelRequest = new Button();
|
||||||
btnMessage = new Button();
|
btnMessage = new Button();
|
||||||
pbUserStatus = new PictureBox();
|
|
||||||
pbCurrencyIcon = new PictureBox();
|
pbCurrencyIcon = new PictureBox();
|
||||||
lblCurrencyAmount = new Label();
|
lblCurrencyAmount = new Label();
|
||||||
flpUsernameCurrency = new FlowLayoutPanel();
|
flpUsernameCurrency = new FlowLayoutPanel();
|
||||||
pCurrency = new Panel();
|
pCurrency = new Panel();
|
||||||
((System.ComponentModel.ISupportInitialize)pbUserPfp).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pbUserPfp).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)pbUserStatus).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pbCurrencyIcon).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pbCurrencyIcon).BeginInit();
|
||||||
flpUsernameCurrency.SuspendLayout();
|
flpUsernameCurrency.SuspendLayout();
|
||||||
pCurrency.SuspendLayout();
|
pCurrency.SuspendLayout();
|
||||||
@ -52,9 +50,9 @@
|
|||||||
// pbUserPfp
|
// pbUserPfp
|
||||||
//
|
//
|
||||||
pbUserPfp.Image = Properties.Resources.DefaultPfp;
|
pbUserPfp.Image = Properties.Resources.DefaultPfp;
|
||||||
pbUserPfp.Location = new Point(13, 11);
|
pbUserPfp.Location = new Point(9, 5);
|
||||||
pbUserPfp.Name = "pbUserPfp";
|
pbUserPfp.Name = "pbUserPfp";
|
||||||
pbUserPfp.Size = new Size(128, 128);
|
pbUserPfp.Size = new Size(139, 138);
|
||||||
pbUserPfp.SizeMode = PictureBoxSizeMode.StretchImage;
|
pbUserPfp.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||||
pbUserPfp.TabIndex = 2;
|
pbUserPfp.TabIndex = 2;
|
||||||
pbUserPfp.TabStop = false;
|
pbUserPfp.TabStop = false;
|
||||||
@ -148,17 +146,6 @@
|
|||||||
btnMessage.Visible = false;
|
btnMessage.Visible = false;
|
||||||
btnMessage.Click += btnMessage_Click;
|
btnMessage.Click += btnMessage_Click;
|
||||||
//
|
//
|
||||||
// pbUserStatus
|
|
||||||
//
|
|
||||||
pbUserStatus.BackColor = Color.Transparent;
|
|
||||||
pbUserStatus.Image = Properties.Resources.OfflineIcon;
|
|
||||||
pbUserStatus.Location = new Point(115, 1);
|
|
||||||
pbUserStatus.Name = "pbUserStatus";
|
|
||||||
pbUserStatus.Size = new Size(32, 32);
|
|
||||||
pbUserStatus.SizeMode = PictureBoxSizeMode.StretchImage;
|
|
||||||
pbUserStatus.TabIndex = 10;
|
|
||||||
pbUserStatus.TabStop = false;
|
|
||||||
//
|
|
||||||
// pbCurrencyIcon
|
// pbCurrencyIcon
|
||||||
//
|
//
|
||||||
pbCurrencyIcon.Image = Properties.Resources.CurrencyIcon;
|
pbCurrencyIcon.Image = Properties.Resources.CurrencyIcon;
|
||||||
@ -213,7 +200,6 @@
|
|||||||
Controls.Add(btnAccept);
|
Controls.Add(btnAccept);
|
||||||
Controls.Add(btnDecline);
|
Controls.Add(btnDecline);
|
||||||
Controls.Add(btnCancelRequest);
|
Controls.Add(btnCancelRequest);
|
||||||
Controls.Add(pbUserStatus);
|
|
||||||
Controls.Add(btnAddContact);
|
Controls.Add(btnAddContact);
|
||||||
Controls.Add(rtxtBio);
|
Controls.Add(rtxtBio);
|
||||||
Controls.Add(pbUserPfp);
|
Controls.Add(pbUserPfp);
|
||||||
@ -230,7 +216,6 @@
|
|||||||
FormClosed += Profile_FormClosed;
|
FormClosed += Profile_FormClosed;
|
||||||
Load += frmProfile_Load;
|
Load += frmProfile_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)pbUserPfp).EndInit();
|
((System.ComponentModel.ISupportInitialize)pbUserPfp).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)pbUserStatus).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pbCurrencyIcon).EndInit();
|
((System.ComponentModel.ISupportInitialize)pbCurrencyIcon).EndInit();
|
||||||
flpUsernameCurrency.ResumeLayout(false);
|
flpUsernameCurrency.ResumeLayout(false);
|
||||||
flpUsernameCurrency.PerformLayout();
|
flpUsernameCurrency.PerformLayout();
|
||||||
@ -249,7 +234,6 @@
|
|||||||
private Button btnDecline;
|
private Button btnDecline;
|
||||||
private Button btnCancelRequest;
|
private Button btnCancelRequest;
|
||||||
private Button btnMessage;
|
private Button btnMessage;
|
||||||
private PictureBox pbUserStatus;
|
|
||||||
private PictureBox pbCurrencyIcon;
|
private PictureBox pbCurrencyIcon;
|
||||||
private Label lblCurrencyAmount;
|
private Label lblCurrencyAmount;
|
||||||
private FlowLayoutPanel flpUsernameCurrency;
|
private FlowLayoutPanel flpUsernameCurrency;
|
||||||
|
@ -51,58 +51,44 @@ namespace qtc_net_client_2.Forms
|
|||||||
lblCurrencyAmount.Text = _userInformationDto.CurrencyAmount.ToString("N0");
|
lblCurrencyAmount.Text = _userInformationDto.CurrencyAmount.ToString("N0");
|
||||||
rtxtBio.Text = _userInformationDto.Bio;
|
rtxtBio.Text = _userInformationDto.Bio;
|
||||||
|
|
||||||
pbUserPfp.Location = new(13, 11);
|
Bitmap? pfp = null;
|
||||||
pbUserPfp.Size = new(128, 128);
|
|
||||||
|
|
||||||
if (pfpRes != null && pfpRes.Success && pfpRes.Data != null)
|
if (pfpRes != null && pfpRes.Success && pfpRes.Data != null)
|
||||||
{
|
{
|
||||||
using (var ms = new MemoryStream(pfpRes.Data))
|
using (var ms = new MemoryStream(pfpRes.Data))
|
||||||
{
|
{
|
||||||
pbUserPfp.Image = new Bitmap(ms);
|
pfp = new Bitmap(ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var userStatus = (UserStatus)_userInformationDto.Status;
|
var userStatus = (UserStatus)_userInformationDto.Status;
|
||||||
|
Bitmap precenseImage = Resources.OnlineIcon;
|
||||||
switch (userStatus)
|
switch (userStatus)
|
||||||
{
|
{
|
||||||
case UserStatus.Online:
|
case UserStatus.Online:
|
||||||
pbUserStatus.Image = Resources.OnlineIcon;
|
precenseImage = Resources.OnlineIcon;
|
||||||
break;
|
break;
|
||||||
case UserStatus.Away:
|
case UserStatus.Away:
|
||||||
pbUserStatus.Image = Resources.AwayIcon;
|
precenseImage = Resources.AwayIcon;
|
||||||
break;
|
break;
|
||||||
case UserStatus.DoNotDisturb:
|
case UserStatus.DoNotDisturb:
|
||||||
pbUserStatus.Image = Resources.DNDIcon;
|
precenseImage = Resources.DNDIcon;
|
||||||
break;
|
break;
|
||||||
case UserStatus.Offline:
|
case UserStatus.Offline:
|
||||||
pbUserStatus.Image = Resources.OfflineIcon;
|
precenseImage = Resources.OfflineIcon;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bitmap? cosmetic = null;
|
||||||
if(cosmeticRes != null)
|
if(cosmeticRes != null)
|
||||||
{
|
{
|
||||||
using var ms = new MemoryStream(cosmeticRes);
|
using var ms = new MemoryStream(cosmeticRes);
|
||||||
CombineProfileImageWithCosmetic(pbUserPfp.Image, new Bitmap(ms));
|
cosmetic = new Bitmap(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_userInformationDto.ProfileCosmeticId != 0)
|
CreateProfileImage(precenseImage, pfp, cosmetic);
|
||||||
{
|
precenseImage.Dispose();
|
||||||
var res = await _apiService.GetStoreItem(_userInformationDto.ProfileCosmeticId);
|
pfp?.Dispose();
|
||||||
if (res != null && res.Success && res.Data != null)
|
cosmetic?.Dispose();
|
||||||
{
|
|
||||||
var client = new HttpClient();
|
|
||||||
var response = await client.GetAsync(res.Data.AssetUrl);
|
|
||||||
if (response.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
using (var stream = await response.Content.ReadAsStreamAsync())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
response.Dispose();
|
|
||||||
}
|
|
||||||
client.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_userInformationDto.Id == _apiService.CurrentUser!.Id)
|
if (_userInformationDto.Id == _apiService.CurrentUser!.Id)
|
||||||
{
|
{
|
||||||
@ -253,22 +239,30 @@ namespace qtc_net_client_2.Forms
|
|||||||
frmDirectMessage.Show();
|
frmDirectMessage.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CombineProfileImageWithCosmetic(Image pfp, Bitmap cosmetic)
|
private void CreateProfileImage(Bitmap precenseImage, Bitmap? pfp = null, Bitmap? cosmetic = null)
|
||||||
{
|
{
|
||||||
cosmetic.MakeTransparent();
|
|
||||||
Bitmap combined = new Bitmap(139, 138);
|
Bitmap combined = new Bitmap(139, 138);
|
||||||
|
|
||||||
using (Graphics g = Graphics.FromImage(combined))
|
using Graphics g = Graphics.FromImage(combined);
|
||||||
{
|
g.Clear(Color.Transparent);
|
||||||
g.Clear(Color.Transparent);
|
g.CompositingMode = CompositingMode.SourceOver;
|
||||||
g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
|
|
||||||
|
|
||||||
|
if (pfp != null)
|
||||||
|
{
|
||||||
|
pfp.MakeTransparent();
|
||||||
g.DrawImage(pfp, 4, 6, 128, 128);
|
g.DrawImage(pfp, 4, 6, 128, 128);
|
||||||
|
}
|
||||||
|
else g.DrawImage(pbUserPfp.Image, 4, 6, 128, 128);
|
||||||
|
|
||||||
|
if (cosmetic != null)
|
||||||
|
{
|
||||||
|
cosmetic.MakeTransparent();
|
||||||
g.DrawImage(cosmetic, 0, 0, 139, 138);
|
g.DrawImage(cosmetic, 0, 0, 139, 138);
|
||||||
}
|
}
|
||||||
|
|
||||||
pbUserPfp.Location = new(9, 5);
|
precenseImage.MakeTransparent();
|
||||||
pbUserPfp.Size = new(139, 138);
|
g.DrawImage(precenseImage, 104, 0, 35, 35);
|
||||||
|
|
||||||
pbUserPfp.Image = combined;
|
pbUserPfp.Image = combined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user