def PortraitDonePress (): pc = GemRB.GameGetSelectedPCSingle () # eh, different sizes if GameCheck.IsBG2(): GemRB.FillPlayerInfo (pc, Portrait.Name () + "M", Portrait.Name () + "S") else: GemRB.FillPlayerInfo (pc, Portrait.Name () + "L", Portrait.Name () + "S") CloseSubCustomizeWindow () return
def PortraitDonePress(): pc = GemRB.GameGetSelectedPCSingle() # eh, different sizes if GameCheck.IsBG2(): GemRB.FillPlayerInfo(pc, Portrait.Name() + "M", Portrait.Name() + "S") else: GemRB.FillPlayerInfo(pc, Portrait.Name() + "L", Portrait.Name() + "S") GemRB.GetView("SUB_WIN", 0).Close() return
def OpenPortraitSelectWindow(): global PortraitPictureButton SubCustomizeWindow = GemRB.LoadWindow(18) SubCustomizeWindow.AddAlias("SUB_WIN", 0) PortraitPictureButton = SubCustomizeWindow.GetControl(0) PortraitPictureButton.SetFlags( IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_NO_IMAGE, OP_SET) PortraitPictureButton.SetState(IE_GUI_BUTTON_LOCKED) PortraitLeftButton = SubCustomizeWindow.GetControl(1) PortraitLeftButton.SetState(IE_GUI_BUTTON_ENABLED) PortraitLeftButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitLeftPress) PortraitRightButton = SubCustomizeWindow.GetControl(2) PortraitRightButton.SetState(IE_GUI_BUTTON_ENABLED) PortraitRightButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitRightPress) PortraitDoneButton = SubCustomizeWindow.GetControl(3) PortraitDoneButton.SetState(IE_GUI_BUTTON_ENABLED) PortraitDoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitDonePress) PortraitDoneButton.SetText(11973) PortraitDoneButton.MakeDefault() PortraitCancelButton = SubCustomizeWindow.GetControl(4) PortraitCancelButton.SetState(IE_GUI_BUTTON_ENABLED) PortraitCancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, lambda: SubCustomizeWindow.Close()) PortraitCancelButton.SetText(13727) PortraitCancelButton.MakeEscape() PortraitCustomButton = SubCustomizeWindow.GetControl(5) PortraitCustomButton.SetState(IE_GUI_BUTTON_ENABLED) PortraitCustomButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenCustomPortraitWindow) PortraitCustomButton.SetText(17545) # get players gender and portrait Pc = GemRB.GameGetSelectedPCSingle() PcPortrait = GemRB.GetPlayerPortrait(Pc, 0)["ResRef"] # initialize and set portrait Portrait.Init(Gender) Portrait.Set(PcPortrait) PortraitPictureButton.SetPicture(Portrait.Name() + PortraitNameSuffix, "NOPORTLG") SubCustomizeWindow.ShowModal(MODAL_SHADOW_GRAY) return
def OpenPortraitSelectWindow(): global CharGenWindow, PortraitWindow, PortraitPictureButton PortraitWindow = GemRB.LoadWindow(18) PortraitPictureButton = PortraitWindow.GetControl(0) PortraitPictureButton.SetFlags( IE_GUI_BUTTON_PICTURE | IE_GUI_BUTTON_NO_IMAGE, OP_SET) PortraitLeftButton = PortraitWindow.GetControl(1) PortraitLeftButton.SetState(IE_GUI_BUTTON_ENABLED) PortraitLeftButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitLeftPress) PortraitLeftButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR) PortraitRightButton = PortraitWindow.GetControl(2) PortraitRightButton.SetState(IE_GUI_BUTTON_ENABLED) PortraitRightButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitRightPress) PortraitRightButton.SetFlags(IE_GUI_BUTTON_RADIOBUTTON, OP_OR) PortraitCustomButton = PortraitWindow.GetControl(5) PortraitCustomButton.SetState(IE_GUI_BUTTON_ENABLED) PortraitCustomButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, OpenCustomPortraitWindow) PortraitCustomButton.SetText(17545) PortraitDoneButton = PortraitWindow.GetControl(3) PortraitDoneButton.SetState(IE_GUI_BUTTON_ENABLED) PortraitDoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitDonePress) PortraitDoneButton.SetText(11973) PortraitDoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT, OP_OR) PortraitCancelButton = PortraitWindow.GetControl(4) PortraitCancelButton.SetState(IE_GUI_BUTTON_ENABLED) PortraitCancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, PortraitCancelPress) PortraitCancelButton.SetText(13727) PortraitCancelButton.SetFlags(IE_GUI_BUTTON_CANCEL, OP_OR) # get players gender and portrait Pc = GemRB.GameGetSelectedPCSingle() PcGender = GemRB.GetPlayerStat(Pc, IE_SEX) PcPortrait = GemRB.GetPlayerPortrait(Pc, 0) # initialize and set portrait Portrait.Init(PcGender) Portrait.Set(PcPortrait) PortraitPictureButton.SetPicture(Portrait.Name() + "G") PortraitWindow.ShowModal(MODAL_SHADOW_GRAY) return
def face_(self): if s.is_empty(): self.open() else: self.make_duplicate() path = s.peek() whitening = self.whitening.value() smoothing = self.smoothing.value() thinface = self.thinface.value() shrink_face = self.shrink_face.value() enlarge_eye = self.enlarge_eye.value() remove_eyebrow = self.remove_eyebrow.value() p = Portrait() p.face_beautify(path, whitening, smoothing, thinface, shrink_face, enlarge_eye, remove_eyebrow) self.show_()
def PortraitRightPress(): global PortraitPictureButton PortraitPictureButton.SetPicture(Portrait.Next() + PortraitNameSuffix, "NOPORTLG")
def PortraitLeftPress(): global PortraitPictureButton PortraitPictureButton.SetPicture(Portrait.Previous() + PortraitNameSuffix, "NOPORTLG")
def OnLoad(): global ColorWindow, DoneButton, PDollButton global HairTable, SkinTable, ColorTable global HairButton, SkinButton, MajorButton, MinorButton global Color1, Color2, Color3, Color4, PDollResRef ColorWindow = GemRB.LoadWindow(13, "GUICG") CharOverview.PositionCharGenWin(ColorWindow) pc = GemRB.GetVar("Slot") Race = IDLUCommon.GetRace(pc) RaceName = CommonTables.Races.GetRowName(Race) HairTable = GemRB.LoadTable(CommonTables.Races.GetValue(RaceName, "HAIR")) SkinTable = GemRB.LoadTable(CommonTables.Races.GetValue(RaceName, "SKIN")) ColorTable = GemRB.LoadTable("clowncol") #set these colors to some default Gender = GemRB.GetPlayerStat(pc, IE_SEX) Portrait.Init(Gender) Portrait.Set(GemRB.GetPlayerPortrait(pc)["ResRef"]) PortraitName = Portrait.Name() # strips the last char like the table needs PortraitTable = GemRB.LoadTable("pictures") Color1 = PortraitTable.GetValue(PortraitName, "HAIR", GTV_INT) Color2 = PortraitTable.GetValue(PortraitName, "SKIN", GTV_INT) Color3 = PortraitTable.GetValue(PortraitName, "MAJOR", GTV_INT) Color4 = PortraitTable.GetValue(PortraitName, "MINOR", GTV_INT) PDollButton = ColorWindow.GetControl(1) PDollButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR) PDollButton.SetState(IE_GUI_BUTTON_LOCKED) HairButton = ColorWindow.GetControl(2) HairButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR) HairButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, HairPress) HairButton.SetBAM("COLGRAD", 1, 0, Color1) SkinButton = ColorWindow.GetControl(3) SkinButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR) SkinButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, SkinPress) SkinButton.SetBAM("COLGRAD", 1, 0, Color2) MajorButton = ColorWindow.GetControl(5) MajorButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR) MajorButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, MajorPress) MajorButton.SetBAM("COLGRAD", 1, 0, Color3) MinorButton = ColorWindow.GetControl(4) MinorButton.SetFlags(IE_GUI_BUTTON_PICTURE, OP_OR) MinorButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, MinorPress) MinorButton.SetBAM("COLGRAD", 1, 0, Color4) BackButton = ColorWindow.GetControl(13) BackButton.SetText(15416) DoneButton = ColorWindow.GetControl(0) DoneButton.SetText(11973) DoneButton.MakeDefault() DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress) BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress) # calculate the paperdoll animation id from the race, class and gender PDollTable = GemRB.LoadTable("avatars") table = GemRB.LoadTable("avprefr") RaceID = CommonTables.Races.GetValue(RaceName, "ID", GTV_INT) # look up base race if needed if RaceID > 1000: RaceID = RaceID >> 16 Race = CommonTables.Races.FindValue("ID", RaceID) RaceName = CommonTables.Races.GetRowName(Race) AnimID = 0x6000 + table.GetValue(RaceName, "RACE") table = GemRB.LoadTable("avprefc") Class = GemRB.GetPlayerStat(pc, IE_CLASS) ClassName = GUICommon.GetClassRowName(Class - 1, "index") AnimID = AnimID + table.GetValue(ClassName, "PREFIX") table = GemRB.LoadTable("avprefg") AnimID = AnimID + table.GetValue(Gender, 0) PDollResRef = PDollTable.GetValue(hex(AnimID), "AT_1") + "G11" if PDollResRef == "*G11": print("ERROR, couldn't find the paperdoll! AnimID is", hex(AnimID)) print("Falling back to an elven paperdoll.") PDollResRef = "CEMB1G11" RefreshPDoll() ColorWindow.Focus() return
import WechatLogin import Portrait import Signature import GetLocation import Gender WechatLogin.weChatLogin() Portrait.getPortrait() Signature.getSignature() GetLocation.getLocation() Gender.getGender()
def main(): sourceImagelocation = "Lenna.png" windowNameFilter = "Filter" windowNameAll = "All" TotalImageSize = (4, 3) allFilters = list() allFilters.append(Portrait.Portrait(sourceImagelocation)) allFilters.append(Portrait.SobelXFilter(sourceImagelocation)) allFilters.append(Portrait.SobelYFilter(sourceImagelocation)) allFilters.append(Portrait.SobelFilter(sourceImagelocation)) allFilters.append(Portrait.LaPlacianFilter(sourceImagelocation)) allFilters.append(Portrait.CannyEdgeFilter(sourceImagelocation)) allFilters.append(Portrait.BlurFilter(sourceImagelocation)) allFilters.append(Portrait.GaussianBlurFilter(sourceImagelocation)) allFilters.append(Portrait.ThresholdFilter(sourceImagelocation)) allFilters.append(Portrait.ErodeFilter(sourceImagelocation)) allFilters.append(Portrait.DilateFilter(sourceImagelocation)) totalImageCol = 0 totalImageRow = 0 image = allFilters[0].GetImage() imageHeight = image.shape[0] imageWidth = image.shape[1] imageDepth = image.shape[2] imageAll = np.zeros((imageHeight * TotalImageSize[1], imageWidth * TotalImageSize[0], imageDepth), dtype=np.uint8) for filter in allFilters: image = filter.GetImage() imageAll[totalImageRow * imageHeight:(totalImageRow + 1) * imageHeight, totalImageCol * imageWidth:(totalImageCol + 1) * imageWidth] = image cv2.imshow(windowNameFilter, image) cv2.waitKey() totalImageCol += 1 if totalImageCol >= TotalImageSize[0]: totalImageCol = 0 totalImageRow += 1 if totalImageRow >= TotalImageSize[1]: break cv2.destroyWindow(windowNameFilter) scale = 600.0 / max(imageAll.shape[0], imageAll.shape[1]) filename, file_extension = os.path.splitext(sourceImagelocation) cv2.imwrite(filename + "_Collage" + file_extension, imageAll) imageAll = cv2.resize( imageAll, (int(imageAll.shape[1] * scale), int(imageAll.shape[0] * scale))) cv2.imshow(windowNameAll, imageAll) cv2.waitKey()
def PortraitDonePress(): pc = GemRB.GameGetSelectedPCSingle() GemRB.FillPlayerInfo(pc, Portrait.Name() + "L", Portrait.Name() + "S") ClosePortraitWindow() return
def PortraitRightPress(): global PortraitPictureButton PortraitPictureButton.SetPicture(Portrait.Next() + "G")
def PortraitLeftPress(): global PortraitPictureButton PortraitPictureButton.SetPicture(Portrait.Previous() + "G")